diff --git a/README.md b/README.md index a62b5200dce9d381f3d2cca708ad12a66a523955..26dbb2e22e5e3113a73697855b04ae96f3038022 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ ### Give it a try today To use as a docker action using python 3 ``` -wsk action update myAction myAction.py --docker openwhisk/python3action:1.0.1 +wsk action update myAction myAction.py --docker openwhisk/python3action:1.0.2 ``` Replace `python3action` with `python2action` to use python 2. diff --git a/core/python2Action/CHANGELOG.md b/core/python2Action/CHANGELOG.md index 02f594941925dbeb2d6f0ca3834e1b33d9593e71..7a308482057fde7336d08952568fbe3675cc7070 100644 --- a/core/python2Action/CHANGELOG.md +++ b/core/python2Action/CHANGELOG.md @@ -19,6 +19,10 @@ # Python 2 OpenWhisk Runtime Container +## 1.0.2 +Changes: + - Update base image to openwhisk/dockerskeleton:1.3.2 + ## 1.0.1 Changes: - Update base image to openwhisk/dockerskeleton:1.3.1 diff --git a/core/python2Action/Dockerfile b/core/python2Action/Dockerfile index dd374f685d384a19cfceb5af61e5317ba0c6c2ae..af00eba9c95ba14cdf76e24f24326f9c9dc69e6e 100644 --- a/core/python2Action/Dockerfile +++ b/core/python2Action/Dockerfile @@ -50,8 +50,9 @@ RUN pip install --no-cache-dir --upgrade pip setuptools six \ ENV FLASK_PROXY_PORT 8080 # Add the action proxy -ADD https://raw.githubusercontent.com/apache/incubator-openwhisk-runtime-docker/dockerskeleton%401.3.1/core/actionProxy/actionproxy.py /actionProxy/actionproxy.py +ADD https://raw.githubusercontent.com/apache/incubator-openwhisk-runtime-docker/dockerskeleton%401.3.2/core/actionProxy/actionproxy.py /actionProxy/actionproxy.py ADD pythonrunner.py /pythonAction/ +RUN rm -rf /action CMD ["/bin/bash", "-c", "cd pythonAction && python -u pythonrunner.py"] diff --git a/core/pythonAction/CHANGELOG.md b/core/pythonAction/CHANGELOG.md index 9f954636bb42a6a6602ad6065b210f0bc7bcacf7..34eba5c4813d0f2f8b8f9d112ef9add8c2e44f83 100644 --- a/core/pythonAction/CHANGELOG.md +++ b/core/pythonAction/CHANGELOG.md @@ -19,6 +19,10 @@ # Python 3 OpenWhisk Runtime Container +## 1.0.2 +Changes: + - Update base image to openwhisk/dockerskeleton:1.3.2 + ## 1.0.1 Changes: - Update base image to openwhisk/dockerskeleton:1.3.1 diff --git a/core/pythonAction/Dockerfile b/core/pythonAction/Dockerfile index 1f4873b9b68b554b533bb8c76bb6d5914738cc61..3021fa890ff01661889bf3566ca1550fd61d8afc 100644 --- a/core/pythonAction/Dockerfile +++ b/core/pythonAction/Dockerfile @@ -16,7 +16,7 @@ # # Dockerfile for python actions, overrides and extends ActionRunner from actionProxy -FROM openwhisk/dockerskeleton:1.3.1 +FROM openwhisk/dockerskeleton:1.3.2 RUN apk add --no-cache \ bzip2-dev \ @@ -45,5 +45,6 @@ ENV FLASK_PROXY_PORT 8080 RUN mkdir -p /pythonAction ADD pythonrunner.py /pythonAction/ +RUN rm -rf /action CMD ["/bin/bash", "-c", "cd pythonAction && python -u pythonrunner.py"] diff --git a/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala index ecc40e38de886c943e72bd12d9c678b716421b08..9dcdee5703cea990dc7b40adc06f28f05ef1aea0 100644 --- a/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala +++ b/tests/src/test/scala/runtime/actionContainers/PythonActionContainerTests.scala @@ -42,87 +42,78 @@ class PythonActionContainerTests extends BasicActionRunnerTests with WskActorSys behavior of imageName - testNotReturningJson( - """ - |def main(args): - | return "not a json object" - """.stripMargin, - checkResultInLogs = false) - - testEcho(Seq { - ( - "python", + override val testNoSourceOrExec = TestConfig("") + override val testNoSource = TestConfig("", hasCodeStub = true) + + override val testNotReturningJson = + TestConfig(""" + |def main(args): + | return "not a json object" + """.stripMargin) + + override val testInitCannotBeCalledMoreThanOnce = + TestConfig(""" + |def main(args): + | return args + """.stripMargin) + + override val testEntryPointOtherThanMain = + TestConfig( + """ + |def niam(args): + | return args + """.stripMargin, + main = "niam") + + override val testEcho = + TestConfig(""" + |from __future__ import print_function + |import sys + |def main(args): + | print('hello stdout') + | print('hello stderr', file=sys.stderr) + | return args + """.stripMargin) + + override val testUnicode = + TestConfig(if (pythonStringAsUnicode) { """ - |from __future__ import print_function - |import sys - |def main(args): - | print('hello stdout') - | print('hello stderr', file=sys.stderr) - | return args - """.stripMargin) - }) - - testUnicode(Seq { - if (pythonStringAsUnicode) { - ( - "python", - """ - |def main(args): - | sep = args['delimiter'] - | str = sep + " ☃ " + sep - | print(str) - | return {"winter" : str } - """.stripMargin.trim) + |def main(args): + | sep = args['delimiter'] + | str = sep + " ☃ " + sep + | print(str) + | return {"winter" : str } + """.stripMargin.trim } else { - ( - "python", - """ - |def main(args): - | sep = args['delimiter'] - | str = sep + " ☃ ".decode('utf-8') + sep - | print(str.encode('utf-8')) - | return {"winter" : str } - """.stripMargin.trim) - } - }) - - testEnv(Seq { - ( - "python", """ - |import os - |def main(dict): - | return { - | "api_host": os.environ['__OW_API_HOST'], - | "api_key": os.environ['__OW_API_KEY'], - | "namespace": os.environ['__OW_NAMESPACE'], - | "action_name": os.environ['__OW_ACTION_NAME'], - | "activation_id": os.environ['__OW_ACTIVATION_ID'], - | "deadline": os.environ['__OW_DEADLINE'] - | } - """.stripMargin.trim) - }) - - testInitCannotBeCalledMoreThanOnce(""" + |def main(args): + | sep = args['delimiter'] + | str = sep + " ☃ ".decode('utf-8') + sep + | print(str.encode('utf-8')) + | return {"winter" : str } + """.stripMargin.trim + }) + + override val testEnv = + TestConfig(""" + |import os + |def main(dict): + | return { + | "api_host": os.environ['__OW_API_HOST'], + | "api_key": os.environ['__OW_API_KEY'], + | "namespace": os.environ['__OW_NAMESPACE'], + | "action_name": os.environ['__OW_ACTION_NAME'], + | "activation_id": os.environ['__OW_ACTIVATION_ID'], + | "deadline": os.environ['__OW_DEADLINE'] + | } + """.stripMargin.trim) + + override val testLargeInput = + TestConfig(""" |def main(args): | return args """.stripMargin) - it should "support actions using non-default entry points" in { - withActionContainer() { c => - val code = """ - |def niam(dict): - | return { "result": "it works" } - |""".stripMargin - - val (initCode, initRes) = c.init(initPayload(code, main = "niam")) - initCode should be(200) - - val (_, runRes) = c.run(runPayload(JsObject())) - runRes.get.fields.get("result") shouldBe Some(JsString("it works")) - } - } - it should "support zip-encoded action using non-default entry points" in { val srcs = Seq( Seq("__main__.py") -> """