Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ jobs:
working-directory: runtime
run: |
SHORT_COMMIT=$(git rev-parse --short "$GITHUB_SHA")
./gradlew :core:python3Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=nightly
./gradlew :core:python3Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT
./gradlew :core:python39Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=nightly
./gradlew :core:python39Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT
./gradlew :core:python310Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=nightly
Expand All @@ -102,9 +100,7 @@ jobs:
run: |
RUNTIME_VERSION=${GITHUB_REF_NAME%@*}
IMAGE_TAG=${GITHUB_REF_NAME##*@}
if [ ${RUNTIME_VERSION} == "3" ]; then
RUNTIME="python3Action"
elif [ ${RUNTIME_VERSION} == "39" ]; then
if [ ${RUNTIME_VERSION} == "39" ]; then
RUNTIME="python39Action"
elif [ ${RUNTIME_VERSION} == "310" ]; then
RUNTIME="python310Action"
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ This repository contains sources files needed to build the Python runtimes for A

The following Python runtime versions (with kind & image labels) are generated by the build system:

- Python 3.7 (python:3.7 & openwhisk/action-python-v3.7)
- Python 3.9 (python:3.9 & openwhisk/action-python-v3.9)
- Python 3.10 (python:3.10 & openwhisk/action-python-v3.10)
- Python 3.11 (python:3.11 & openwhisk/action-python-v3.11)
Expand Down Expand Up @@ -90,10 +89,10 @@ To build all those images, run the following command.

You can optionally build a specific image by modifying the gradle command. For example:
```
./gradlew core:python3Action:distDocker
./gradlew core:python311Action:distDocker
```

The build will produce Docker images such as `action-python-v3.7`
The build will produce Docker images such as `action-python-v3.11`
and will also tag the same image with the `whisk/` prefix. The latter
is a convenience, which if you're testing with a local OpenWhisk
stack, allows you to skip pushing the image to Docker Hub.
Expand All @@ -120,11 +119,11 @@ in first with the `docker` CLI.
### Using Your Image as an OpenWhisk Action

You can now use this image as an OpenWhisk action. For example, to use
the image `action-python-v3.7` as an action runtime, you would run
the image `action-python-v3.11` as an action runtime, you would run
the following command.

```
wsk action update myAction myAction.py --docker $DOCKER_USER/action-python-v3.7
wsk action update myAction myAction.py --docker $DOCKER_USER/action-python-v3.11
```

## Test Runtimes
Expand Down Expand Up @@ -178,9 +177,9 @@ The action containers can actually generate a virtualenv for you, provided you h
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:

```
zip -j -r myaction | docker run -i action-python-v3.7 -compile main > myaction.zip
zip -j -r myaction | docker run -i action-python-v3.11 -compile main > myaction.zip
```

You may use `v3.11`, `v3.10`, or `v3.9` as well according to your Python version needs.
You may use `v3.11`, `v3.10`, or `v3.9` according to your Python version needs.

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 build a custom docker image that includes these libraries.
66 changes: 0 additions & 66 deletions core/python3Action/Dockerfile

This file was deleted.

31 changes: 0 additions & 31 deletions core/python3Action/Makefile

This file was deleted.

31 changes: 0 additions & 31 deletions core/python3Action/build.gradle

This file was deleted.

2 changes: 0 additions & 2 deletions core/python3Action/requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

include 'tests'

include 'core:python3Action'
include 'core:python39Action'
include 'core:python310Action'
include 'core:python311Action'
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/resources/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if [ -f ".built" ]; then
exit 0
fi

for i in v3.7 v3.9 v3.10 v3.11
for i in v3.9 v3.10 v3.11
do echo "*** $i ***"
zip -r -j - python_virtualenv | docker run -i action-python-$i -compile main >python-${i}_virtualenv.zip
cp python-${i}_virtualenv.zip python-${i}_virtualenv_invalid_main.zip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class Python310Tests extends Python37Tests {
class Python310Tests extends Python3Tests {

override lazy val imageName = "action-python-v3.10"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class Python311Tests extends Python37Tests {
class Python311Tests extends Python3Tests {

override lazy val imageName = "action-python-v3.11"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class Python39Tests extends Python37Tests {
class Python39Tests extends Python3Tests {

override lazy val imageName = "action-python-v3.9"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,9 @@ import org.scalatest.junit.JUnitRunner
import spray.json._

@RunWith(classOf[JUnitRunner])
class Python37Tests extends PythonBasicTests with PythonAdvancedTests with WskActorSystem {
abstract class Python3Tests extends PythonBasicTests with PythonAdvancedTests with WskActorSystem {

override lazy val imageName = "action-python-v3.7"

lazy val zipPrefix = "python-v3.7"

override val testNoSource = TestConfig("", hasCodeStub = false)

/** actionloop based image does not log init errors - return the error in the body */
override lazy val errorCodeOnRun = false
lazy val zipPrefix = "???"

def testArtifact(name: String): File = {
new File(this.getClass.getClassLoader.getResource(name).toURI)
Expand Down
18 changes: 9 additions & 9 deletions tutorials/local_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,45 +32,45 @@ cd openwhisk-runtime-python

## Build the docker image

Build docker image using Python 3.7 (recommended). This tutorial assumes you're building with python 3.7.
Build docker image using Python 3.11 (recommended). This tutorial assumes you're building with python 3.11.
Run `local_build.sh` to build docker. This script takes two parameters as input
- `-r` Specific runtime image folder name to be built, it can be one of `python3Action`, `python39Action`, `python310Action`, or `python311Action`
- `-t` The name for docker image and tag used for building the docker image. Example: `action-python-v3.7:1.0-SNAPSHOT`
- `-r` Specific runtime image folder name to be built, it can be one of `python39Action`, `python310Action`, or `python311Action`
- `-t` The name for docker image and tag used for building the docker image. Example: `action-python-v3.11:1.0-SNAPSHOT`

```
cd tutorials
chmod 755 local_build.sh
cd ..
./tutorials/local_build.sh -r python3Action -t action-python-v3.7:1.0-SNAPSHOT
./tutorials/local_build.sh -r python311Action -t action-python-v3.11:1.0-SNAPSHOT
```

### Verify docker image

Check docker `IMAGE ID` (3rd column) for repository `action-python-v3.7`
Check docker `IMAGE ID` (3rd column) for repository `action-python-v3.11`
```
docker images
```
If the `local_build.sh` script is sucessful, you should see an image that looks something like:
```
action-python-v3.7 1.0-SNAPSHOT ...
action-python-v3.11 1.0-SNAPSHOT ...
```

### (Optional) Tag docker image

This is required if you’re pushing your docker image to a registry e.g. dockerHub
```
docker tag <docker_image_ID> <dockerHub_username>/action-python-v3.7:1.0-SNAPSHOT
docker tag <docker_image_ID> <dockerHub_username>/action-python-v3.11:1.0-SNAPSHOT
```

## Run docker image

Run docker on localhost with either the following commands:
```
docker run -p 127.0.0.1:80:8080/tcp --name=bloom_whisker --rm -it action-python-v3.7:1.0-SNAPSHOT
docker run -p 127.0.0.1:80:8080/tcp --name=bloom_whisker --rm -it action-python-v3.11:1.0-SNAPSHOT
```
Or run the container in the background (Add -d (detached) to the command above)
```
docker run -d -p 127.0.0.1:80:8080/tcp --name=bloom_whisker --rm -it action-python-v3.7:1.0-SNAPSHOT
docker run -d -p 127.0.0.1:80:8080/tcp --name=bloom_whisker --rm -it action-python-v3.11:1.0-SNAPSHOT
```
**Note:** If you run your docker container in the background you'll want to stop it with:
```
Expand Down
14 changes: 4 additions & 10 deletions tutorials/local_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ helperInstructions()
{
echo ""
echo "Usage: $0 -r runtimeParameter -t dockerImageTag"
echo -e "\t-r Specific runtime image folder name to be built, it can be one of python3Action, python39Action, python310Action, or python311Action"
echo -e "\t-t The name for docker image and tag used for building the docker image. Example: action-python-v3.7:1.0-SNAPSHOT"
echo -e "\t-r Specific runtime image folder name to be built, it can be one of python39Action, python310Action, or python311Action"
echo -e "\t-t The name for docker image and tag used for building the docker image. Example: action-python-v3.11:1.0-SNAPSHOT"
exit 1 #Exit script
}

Expand All @@ -35,20 +35,14 @@ do
done

# Print helperInstructions in case parameters are empty
if [ -z "$runtimeParameter" ] || [ -z "$dockerImageTag" ] || ( [[ "$runtimeParameter" != "python3Action" ]] && [[ "$runtimeParameter" != "python39Action" ]] && [[ "$runtimeParameter" != "python310Action" ]] && [[ "$runtimeParameter" != "python311Action" ]] )
if [ -z "$runtimeParameter" ] || [ -z "$dockerImageTag" ] || ( [[ "$runtimeParameter" != "python39Action" ]] && [[ "$runtimeParameter" != "python310Action" ]] && [[ "$runtimeParameter" != "python311Action" ]] )
then
echo "Runtime parameter is empty or not supported";
helperInstructions
fi

# For every runtime 1. copy the required dependent folders 2. build the docker image 3. delete the copied folder
if [[ "$runtimeParameter" == "python3Action" ]]
then
echo "Building docker for python3Action."
cp $(pwd)/core/requirements_common.txt $(pwd)/core/python3Action/requirements_common.txt
docker build -t "$dockerImageTag" $(pwd)/core/python3Action
rm $(pwd)/core/python3Action/requirements_common.txt
elif [[ "$runtimeParameter" == "python39Action" ]]
if [[ "$runtimeParameter" == "python39Action" ]]
then
echo "Building docker for python39Action."
cp $(pwd)/core/requirements_common.txt $(pwd)/core/python39Action/requirements_common.txt
Expand Down