What packages are available to your OpenWhisk Python actions?
The OpenWhisk build process now publishes to DockerHub the images of the containers that your actions will run in. Exploring these images is helpful in understanding the art of the possible within OpenWhisk. For instance, when building actions, it is helpful to know what version of Python and what third party packages will be available at runtime. This knowledge will be essential to properly testing your actions before deploying them.
Of course, all of this information is carefully documented but I know that some of you folks are from the show me state. So, this short note will guide you through the process of:
- Pulling down the latest Python action image from DockerHub
- Opening that as a container in interactive mode on your local machine
- Using Python and pip to get a lay of the land
The following assumes that you have Docker installed on the local machine:
$ docker pull openwhisk/python3action
$ docker run -it openwhisk/python3action /bin/bash # into container
# ls # "Toto, I've a feeling we're not in Kansas anymore."
# python -V # Python 3.6.1
# python3 -V # Python 3.6.1
# python2 -V # That dog won’t hunt
# pip -V # pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
# pip3 -V # pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
# pip freeze # Left as an exercise for the reader
# exit
$
To get a sense of the environment for Python 2 actions, change python3action to python2action on both of the first two lines. This leaves open the question of how to deal with the situations where a required package is not present or where a included package is the wrong version for our needs. A nodejs solution is discussed in A Tip for Zipped Actions and Packages in OpenWhisk and a Python solution is discussed in Python Packages in OpenWhisk.