You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* implementes python39, support for building venv with requirements.txt, updated tests
* removed useless test, fixed a typo
Co-authored-by: Michele Sciabarra <michele@sciabarra.com>
This action runtime enables developers to create AI Services with OpenWhisk. It comes with preinstalled libraries useful for running machine learning and deep learning inferences. [Read more about this runtime here](./core/python3AiActionLoop).
406
+
This action runtime enables developers to create AI Services with OpenWhisk. It comes with preinstalled libraries useful for running machine learning and deep learning inferences. [Read more about this runtime here](./core/python3AiAction).
408
407
409
408
## Import Project into IntelliJ
410
409
411
410
Follow these steps to import the project into your IntelliJ IDE.
412
411
- Import project as gradle project.
413
412
- Make sure the working directory is root of the project/repo.
413
+
414
+
# Using extra libraries
415
+
416
+
If you need more libraries for your Python action, you can include a virtualenv in the zip file of the action.
417
+
418
+
The requirement is that the zip file must have a subfolder named `virtualenv` with a script `virtualenv\bin\activate_this.py` working in an Linux AMD64 environment. It will be executed at start time to use your extra libraries.
419
+
420
+
## Using requirements.txt
421
+
422
+
Virtual envs are usually built listing your dependencies in a `requirements.txt`.
423
+
424
+
If you have an action that requires addition libraries, you can just include `requirements.txt`.
425
+
426
+
You have to create a folder `myaction` with at least two files:
427
+
428
+
```
429
+
__main__.py
430
+
requirements.txt
431
+
```
432
+
433
+
Then zip your action and deploy to OpenWhisk, the requirements will be installed for you at init time, creating a suitable virtualenv.
434
+
435
+
Keep in mind that resolving requirements involves downloading and install software, so your action timeout limit may need to be adjusted accordingly. Instead, you should consider using precompilation to resolve the requirements at build time.
436
+
437
+
438
+
## Precompilation of a virtualenv
439
+
440
+
The action containers can actually generate a virtualenv for you, provided you have a requirements.txt.
441
+
442
+
443
+
If you have an action in the format described before (with a `requirements.txt`) you can build the zip file with the included files with:
444
+
445
+
```
446
+
zip -j -r myaction | docker run -i action-python-v3.7 -compile main >myaction.zip
447
+
```
448
+
449
+
You may use `v3.9` or `v3.6-ai` as well according to your Python version needs.
450
+
451
+
The resulting action includes a virtualenv already built for you and that is fast to deploy and start as all the dependencies are already resolved. Note that there is a limit on the size of the zip file and this approach will not work for installing large libraries like Pandas or Numpy, instead use the provide "v.3.6-ai" runtime instead which provides these libraries already for you.
0 commit comments