Skip to content

Commit b24075e

Browse files
authored
Add Python 3.11 Runtime (#140)
Add Pyton 3.11 Runtime (Version as of commit: 3.11.2) Using Golang 1.20 Based Proxy Update Pip modules use fixed packages for 3.11
1 parent 9d0d574 commit b24075e

9 files changed

Lines changed: 172 additions & 3 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ jobs:
9696
./gradlew :core:python39Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT
9797
./gradlew :core:python310Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=nightly
9898
./gradlew :core:python310Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT
99+
./gradlew :core:python311Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=nightly
100+
./gradlew :core:python311Action:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$SHORT_COMMIT
99101
- name: Push Release Images
100102
if: ${{ env.PUSH_RELEASE == 'true' }}
101103
working-directory: runtime
@@ -110,5 +112,7 @@ jobs:
110112
RUNTIME="python39Action"
111113
elif [ ${RUNTIME_VERSION} == "310" ]; then
112114
RUNTIME="python310Action"
115+
elif [ ${RUNTIME_VERSION} == "311" ]; then
116+
RUNTIME="python311Action"
113117
fi
114118
./gradlew :core:$RUNTIME:distDocker -PdockerRegistry=docker.io -PdockerImagePrefix=openwhisk -PdockerImageTag=$IMAGE_TAG

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The following Python runtime versions (with kind & image labels) are generated b
2828
- Python 3.7 (python:3.7 & openwhisk/action-python-v3.7)
2929
- Python 3.9 (python:3.9 & openwhisk/action-python-v3.9)
3030
- Python 3.10 (python:3.10 & openwhisk/action-python-v3.10)
31+
- Python 3.11 (python:3.11 & openwhisk/action-python-v3.11)
3132
- Python 3.6 AI (python:3.6 & openwhisk/action-python-v3.6-ai)
3233

3334
This README documents the build, customization and testing of these runtime images.
@@ -184,6 +185,6 @@ If you have an action in the format described before (with a `requirements.txt`)
184185
zip -j -r myaction | docker run -i action-python-v3.7 -compile main > myaction.zip
185186
```
186187

187-
You may use `v3.10`, `v3.9` or `v3.6-ai` as well according to your Python version needs.
188+
You may use `v3.11`, `v3.10`, `v3.9` or `v3.6-ai` as well according to your Python version needs.
188189

189190
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.

core/python311Action/Dockerfile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# build go proxy from source
19+
FROM golang:1.20 AS builder_source
20+
ARG GO_PROXY_GITHUB_USER=apache
21+
ARG GO_PROXY_GITHUB_BRANCH=master
22+
RUN git clone --branch ${GO_PROXY_GITHUB_BRANCH} \
23+
https://github.com/${GO_PROXY_GITHUB_USER}/openwhisk-runtime-go /src ;\
24+
cd /src ; env GO111MODULE=on CGO_ENABLED=0 go build main/proxy.go && \
25+
mv proxy /bin/proxy
26+
27+
# or build it from a release
28+
FROM golang:1.20 AS builder_release
29+
ARG GO_PROXY_RELEASE_VERSION=1.20@1.21.0
30+
RUN curl -sL \
31+
https://github.com/apache/openwhisk-runtime-go/archive/{$GO_PROXY_RELEASE_VERSION}.tar.gz\
32+
| tar xzf -\
33+
&& cd openwhisk-runtime-go-*/main\
34+
&& GO111MODULE=on CGO_ENABLED=0 go build -o /bin/proxy
35+
36+
FROM python:3.11-buster
37+
38+
# select the builder to use
39+
ARG GO_PROXY_BUILD_FROM=release
40+
41+
# install zip
42+
RUN apt-get update && apt-get install -y zip gcc \
43+
&& rm -rf /var/lib/apt/lists/*
44+
45+
# Install common modules for python
46+
COPY requirements_common.txt requirements_common.txt
47+
COPY requirements.txt requirements.txt
48+
RUN pip3 install --upgrade pip six wheel &&\
49+
pip3 install --no-cache-dir -r requirements.txt
50+
51+
RUN mkdir -p /action
52+
WORKDIR /
53+
54+
COPY --from=builder_source /bin/proxy /bin/proxy_source
55+
COPY --from=builder_release /bin/proxy /bin/proxy_release
56+
RUN mv /bin/proxy_${GO_PROXY_BUILD_FROM} /bin/proxy
57+
58+
ADD bin/compile /bin/compile
59+
ADD lib/launcher.py /lib/launcher.py
60+
61+
# log initialization errors
62+
ENV OW_LOG_INIT_ERROR=1
63+
# the launcher must wait for an ack
64+
ENV OW_WAIT_FOR_ACK=1
65+
# using the runtime name to identify the execution environment
66+
ENV OW_EXECUTION_ENV=openwhisk/action-python-v3.11
67+
# compiler script
68+
ENV OW_COMPILER=/bin/compile
69+
70+
ENTRYPOINT ["/bin/proxy"]

core/python311Action/build.gradle

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
ext.dockerImageName = 'action-python-v3.11'
19+
apply from: '../../gradle/docker.gradle'
20+
21+
distDocker.dependsOn 'copyLib'
22+
distDocker.dependsOn 'copyBin'
23+
distDocker.dependsOn 'copyReqrCommon'
24+
distDocker.finalizedBy('cleanup')
25+
26+
task copyLib(type: Copy) {
27+
from '../python3Action/lib'
28+
into './lib'
29+
}
30+
31+
task copyBin(type: Copy) {
32+
from '../python3Action/bin'
33+
into './bin'
34+
}
35+
36+
task copyReqrCommon(type: Copy) {
37+
from '../requirements_common.txt'
38+
into './'
39+
}
40+
41+
task cleanup(type: Delete) {
42+
delete 'bin'
43+
delete 'lib'
44+
delete 'requirements_common.txt'
45+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# default packages available for action-python-v3.11
2+
#-r requirements_common.txt
3+
beautifulsoup4==4.11.2
4+
httplib2==0.21.0
5+
kafka_python==2.0.2
6+
lxml==4.9.2
7+
python-dateutil==2.8.2
8+
requests==2.28.2
9+
scrapy==2.8.0
10+
simplejson==3.18.3
11+
virtualenv==20.19.0
12+
twisted==22.10.0
13+
netifaces==0.11.0
14+
# fix issue: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools
15+
setuptools == 67.4.0

core/requirements_common.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ scrapy==2.5.0
99
simplejson==3.17.5
1010
virtualenv==20.8.0
1111
twisted==21.7.0
12-
netifaces==0.11.0
12+
netifaces==0.11.0

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ include 'core:python3Action'
2121
include 'core:python36AiAction'
2222
include 'core:python39Action'
2323
include 'core:python310Action'
24+
include 'core:python311Action'
2425

2526
rootProject.name = 'runtime-python'
2627

tests/src/test/resources/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if [ -f ".built" ]; then
2121
exit 0
2222
fi
2323

24-
for i in v3.7 v3.6-ai v3.9 v3.10
24+
for i in v3.7 v3.6-ai v3.9 v3.10 v3.11
2525
do echo "*** $i ***"
2626
zip -r -j - python_virtualenv | docker run -i action-python-$i -compile main >python-${i}_virtualenv.zip
2727
cp python-${i}_virtualenv.zip python-${i}_virtualenv_invalid_main.zip
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package runtime.actionContainers
19+
20+
import org.junit.runner.RunWith
21+
import org.scalatest.junit.JUnitRunner
22+
23+
@RunWith(classOf[JUnitRunner])
24+
class Python311Tests extends Python37Tests {
25+
26+
override lazy val imageName = "action-python-v3.11"
27+
28+
override lazy val zipPrefix = "python-v3.11"
29+
30+
override lazy val errorCodeOnRun = false
31+
32+
override val testNoSource = TestConfig("", hasCodeStub = false)
33+
}

0 commit comments

Comments
 (0)