Skip to content

dariosm/runtime-python

 
 

Repository files navigation

IBM Cloud Functions Runtime for Python

Build Status

The runtime provides python v3 with a set of python packages

Some of the python packages are to be used on IBM Cloud:

Docker runtime is based on Debian-Jessie/Ubuntu14-Trusty

Hello Action

Write a function using Apache OpenWhisk Serverless programming inteface

def main(args):
    name = args.get("name", "stranger")
    greeting = "Hello " + name + "!"
    print(greeting)
    return {"greeting": greeting}

IBM Cloud Functions (based on Apache OpenWhisk)

To use as a python kind action

bx wsk action update helloPython hello.py --kind python-jessie:3

How to use as a docker Action locally

To use as a docker action

bx wsk action update helloPython hello.py --docker ibmfunctions/action-python-v3

This works on any deployment of Apache OpenWhisk or IBM Cloud Functions

Working with the local git repo

Prerequisite: Export OPENWHISK_HOME to point to your incubator-openwhisk cloned directory.

./gradlew python3:distDocker

This will produce the image whisk/action-python-v3

Build and Push image

docker login
./gradlew python3:distDocker -PdockerImagePrefix=$prefix-user -PdockerRegistry=docker.io

Deploy OpenWhisk using ansible environment that adds the new king python:3 Assuming you have OpenWhisk already deploy localy and OPENWHISK_HOME pointing to root directory of OpenWhisk core repository.

Set ROOTDIR to the root directory of this repository.

Redeploy OpenWhisk

cd $OPENWHISK_HOME/ansible
ANSIBLE_CMD="ansible-playbook -i ${ROOTDIR}/ansible/environments/local"
$ANSIBLE_CMD setup.yml
$ANSIBLE_CMD couchdb.yml
$ANSIBLE_CMD initdb.yml
$ANSIBLE_CMD wipe.yml
$ANSIBLE_CMD openwhisk.yml

To use as docker action push to your own dockerhub account

docker tag whisk/action-python-v3 $user_prefix/action-python-v3
docker push $user_prefix/action-python-v3

Then create the action using your the image from dockerhub

wsk action update myAction myAction.py --docker $user_prefix/action-python-v3

The $user_prefix is usually your dockerhub user id.

Testing

Install dependencies from the root directory on $OPENWHISK_HOME repository

./gradlew install

Using gradle to run all tests

./gradlew :tests:test

Using gradle to run some tests

./gradlew :tests:test --tests *ActionContainerTests*

Using IntelliJ:

  • Import project as gradle project.
  • Make sure working directory is root of the project/repo

Using container image to test

To use as docker action push to your own dockerhub account

docker tag whisk/action-python-v3 $user_prefix/action-python-v3
docker push $user_prefix/action-python-v3

Then create the action using your the image from dockerhub

wsk action update myAction myAction.py --docker $user_prefix/action-python-v3

The $user_prefix is usually your dockerhub user id.

License

Apache 2.0

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 75.5%
  • Python 13.4%
  • Shell 7.7%
  • Dockerfile 3.4%
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy