|
21 | 21 | [](http://www.apache.org/licenses/LICENSE-2.0) |
22 | 22 | [](https://travis-ci.org/apache/openwhisk-runtime-python) |
23 | 23 |
|
| 24 | +## Build Runtimes |
| 25 | + |
| 26 | +The runtimes are built using Gradle. |
| 27 | +The file [settings.gradle](settings.gradle) lists the images that are build by default. |
| 28 | +To build all those images, run the following command. |
24 | 29 |
|
25 | | -### Give it a try today |
26 | | -To use as a docker action using python 3 |
27 | 30 | ``` |
28 | | -wsk action update myAction myAction.py --docker openwhisk/python3action:1.0.2 |
| 31 | +./gradlew distDocker |
29 | 32 | ``` |
30 | 33 |
|
31 | | -### To use on deployment that contains the rutime as a kind |
32 | | -To use as a kind action using python 3 |
| 34 | +You can optionally build a specific image by modifying the Gradle command. For example: |
33 | 35 | ``` |
34 | | -wsk action update myAction myAction.py --kind python:3 |
| 36 | +./gradlew core:python3ActionLoop:distDocker |
35 | 37 | ``` |
36 | | -Replace `python:3` with `python:2` to use python 2. |
37 | 38 |
|
| 39 | +The build will produce Docker images such as `actionloop-python-v3.7` |
| 40 | +and will also tag the same image with the `whisk/` prefix. The latter |
| 41 | +is a convenience, which if you're testing with a local OpenWhisk |
| 42 | +stack, allows you to skip pushing the image to Docker Hub. |
38 | 43 |
|
39 | | -### Python 3 AI Action |
40 | | -This action enables developers to create AI Services with OpenWhisk. It comes with preinstalled libraries useful for running machine learning and deep learning inferences. See more about [python3aiaction](./core/python3AiAction). |
| 44 | +The image will need to be pushed to Docker Hub if you want to test it |
| 45 | +with a hosted OpenWhisk installation. |
41 | 46 |
|
42 | | -### Local development |
43 | | -``` |
44 | | -./gradlew core:pythonAction:distDocker |
45 | | -``` |
46 | | -This will produce the image `whisk/python3action` |
| 47 | +### Using Gradle to push to a Docker Registry |
47 | 48 |
|
48 | | -Build and Push image |
49 | | -``` |
50 | | -docker login |
51 | | -./gradlew core:pythonAction:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io |
52 | | -``` |
| 49 | +The Gradle build parameters `dockerImagePrefix` and `dockerRegistry` |
| 50 | +can be configured for your Docker Registery. Make usre you are logged |
| 51 | +in first with the `docker` CLI. |
53 | 52 |
|
54 | | -Deploy OpenWhisk using ansible environment that contains the kind `python:3` and `python:2` |
55 | | -Assuming you have OpenWhisk already deploy locally and `OPENWHISK_HOME` pointing to root directory of OpenWhisk core repository. |
| 53 | +- Use the `docker` CLI to login. The following assume you will substitute `$DOCKER_USER` with an appropriate value. |
| 54 | + ``` |
| 55 | + docker login --username $DOCKER_USER |
| 56 | + ``` |
56 | 57 |
|
57 | | -Set `ROOTDIR` to the root directory of this repository. |
| 58 | +- Now build, tag and push the image accordingly. |
| 59 | + ``` |
| 60 | + ./gradlew distDocker -PdockerImagePrefix=$DOCKER_USER -PdockerRegistry=docker.io |
| 61 | + ``` |
58 | 62 |
|
59 | | -Redeploy OpenWhisk |
60 | | -``` |
61 | | -cd $OPENWHISK_HOME/ansible |
62 | | -ANSIBLE_CMD="ansible-playbook -i ${ROOTDIR}/ansible/environments/local" |
63 | | -$ANSIBLE_CMD setup.yml |
64 | | -$ANSIBLE_CMD couchdb.yml |
65 | | -$ANSIBLE_CMD initdb.yml |
66 | | -$ANSIBLE_CMD wipe.yml |
67 | | -$ANSIBLE_CMD openwhisk.yml |
68 | | -``` |
| 63 | +### Using Your Image as an OpenWhisk Action |
69 | 64 |
|
70 | | -Or you can use `wskdev` and create a soft link to the target ansible environment, for example: |
71 | | -``` |
72 | | -ln -s ${ROOTDIR}/ansible/environments/local ${OPENWHISK_HOME}/ansible/environments/local-python |
73 | | -wskdev fresh -t local-python |
74 | | -``` |
| 65 | +You can now use this image as an OpenWhisk action. For example, to use |
| 66 | +the image `actionloop-python-v3.7` as an action runtime, you would run |
| 67 | +the following command. |
75 | 68 |
|
76 | | -Use the `docker` commands to tag the image and push it into your own Docker Hub account |
77 | | -``` |
78 | | -docker tag whisk/python3action $user_prefix/python3action |
79 | | -docker push $user_prefix/python3action |
80 | | -``` |
81 | | -Then create the action using your image from dockerhub |
82 | 69 | ``` |
83 | | -wsk action update myAction myAction.py --docker $user_prefix/python3action |
| 70 | +wsk action update myAction myAction.py --docker $DOCKER_USER/actionloop-python-v3.7 |
84 | 71 | ``` |
85 | | -The `$user_prefix` is usually your dockerhub user id. |
86 | 72 |
|
87 | | -### Testing |
88 | | -Install dependencies from the root directory on $OPENWHISK_HOME repository |
| 73 | +## Test Runtimes |
| 74 | + |
| 75 | +There are suites of tests that are generic for all runtimes, and some that are specific to a runtime version. |
| 76 | +To run all tests, there are two steps. |
| 77 | + |
| 78 | +First, you need to create an OpenWhisk snapshot release. Do this from your OpenWhisk home directory. |
89 | 79 | ``` |
90 | 80 | ./gradlew install |
91 | 81 | ``` |
92 | 82 |
|
93 | | -Using gradle for the ActionContainer tests you need to use a proxy if running on Mac, if Linux then don't use proxy options |
94 | | -You can pass the flags `-Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128` directly in gradle command. |
95 | | -Or save in your `$HOME/.gradle/gradle.properties` |
96 | | -``` |
97 | | -systemProp.http.proxyHost=localhost |
98 | | -systemProp.http.proxyPort=3128 |
99 | | -``` |
100 | | -Using gradle to run all tests |
101 | | -``` |
102 | | -./gradlew :tests:test |
103 | | -``` |
104 | | -Using gradle to run some tests |
| 83 | +Now you can build and run the tests in this repository. |
105 | 84 | ``` |
106 | | -./gradlew :tests:test --tests *ActionContainerTests* |
| 85 | +./gradlew tests:test |
107 | 86 | ``` |
108 | | -Using IntelliJ: |
109 | | -- Import project as gradle project. |
110 | | -- Make sure working directory is root of the project/repo |
111 | | -- Add the following Java VM properties in ScalaTests Run Configuration, easiest is to change the Defaults for all ScalaTests to use this VM properties |
| 87 | + |
| 88 | +Gradle allows you to selectively run tests. For example, the following |
| 89 | +command runs tests which match the given pattern and excludes all |
| 90 | +others. |
112 | 91 | ``` |
113 | | --Dhttp.proxyHost=localhost |
114 | | --Dhttp.proxyPort=3128 |
| 92 | +./gradlew :tests:test --tests *ActionLoopContainerTests* |
115 | 93 | ``` |
116 | 94 |
|
| 95 | +## Python 3 AI Runtime |
| 96 | +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). |
| 97 | + |
| 98 | +## Import Project into IntelliJ |
| 99 | + |
| 100 | +Follow these steps to import the project into your IntelliJ IDE. |
| 101 | +- Import project as gradle project. |
| 102 | +- Make sure working directory is root of the project/repo. |
0 commit comments