As per title.
The interesting part will be handling the requirements compiling. Lambda currently punts on this and requires users to upload all the packages (compiled) as part of their code. The problem is if I'm a mac user and compile lxml, it won't run on lambda because it's Amazon Linux. At the most basic level, having whisk run a 'pip install' (maybe even create a virtualenv) of a requirements.txt to get/compile required actions for the user would be big. That's basically what cloud foundry does in it's python buildpack.
I think we can close this for now. Python has been working with basic tests for a while.
@ioana-blue Could you respond to the comment https://github.com/openwhisk/openwhisk/issues/16#issuecomment-196299872
from @vmtyler about how "handling the requirements compiling"?
For now, our solution is similar to the javascript one. We support a series of packages that are (should be) documented. At some point, we may consider a more generalized solution similar to "build packs". @vmtyler
Hello,
Is it possible to use packaged python actions? if yes, any tutorials?
@firasalmanna not an official solution yet. One option is compiling the python to a native binary which you can do with bbfreeze or maybe grumpy (https://github.com/google/grumpy)`. Which packages are you looking at?
@rabbah
I am trying to upload a project I am working on, requirements file attached. the requirements can be reduced as I am dividing my app into microservices, so each will have a subset of these requirements.
So after compiling my app into binary, how am I going to upload it? I don't think I saw this option in the docs.
You can try the approach outlined here (once you have a binary you can create an action from it).
EDIT: apparently forgot to provide the link. Thanks @csantanapr (See below).
@rabbah you meant to share this link Understanding and using Docker actions in IBM Bluemix OpenWhisk that explains how to create a zip with a binary exe so @firasalmanna can use it to create an exec with python.
Hello guys,
I am having a problem after generating an executable and pushing it to openwhisk.
1- I made and executable out of my python app, I tested it locally and then tried to create an openwhisk action from it using the steps in the blog post. When I tried to invoke it, I got the message [Errno 2] No such file or directory
2- I tried to create a docker image, I used dockerskeleton as the base image, I copied my exec to action/exec, I built the image and pushed it, then why I invoked the openwhisk action created from my image, I also received the same error [Errno 2] No such file or directory.
I browsed the docker image files, and I found the exec file in the action directory.
Do you have an idea what could be the problem?
If you can exec into the container, did you run the /action/exec directly to confirm it works?
No, I couldn't run it, I also got No such file or directory
And after some investigation, I think that the executable I generate using pyinstaller is 32-bit because pyinstaller generates 32-bit executable for python 2.7, which I am using.
Then, I found that I can execute 32 on 64 bit if there is the dynamic loader /lib/ld-linux.so.2. But I couldn't find it for alpine-linux using apk add.
The only options I have now is to find a different package for alpine that executes 32-bit, or to try to generate a 64-bit exec again.
@firasalmanna what about using the approach of using bash script exec and then from bash script and then tun setup/unit and run python script (i.e. Not compiled)
Maybe I missed that you already tried this.
Here's another tip following Carlos: you can use this approach with nodejs actions. That is build your binary using the nodejs actio base image if it helps and then call it from a node action.
@csantanapr no I didn't try this approach. I might give it a try.
But first I am thinking if trying the approach from this link https://github.com/iainhouston/dockerPython
He is renamed his python script test.py to exec, and he put it in the action directory, and everything else is the same. He also copied all his other classes to the action directory.
Do you think this should work?
@rabbah do you mean running my script from nodejs? or using this approach to run a nodejs app?
Want to reach out to us on http://slack.openwhisk.org and we can work through it directly?