Git Product home page Git Product logo

runtime-python's Introduction

IBM Cloud Functions Runtime for Python

Build Status

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

Docker runtime is based on Debian/Ubuntu

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:3.7

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

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 openwhisk cloned directory.

./gradlew python3:distDocker

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

Build and Push image

docker login
./gradlew python3.7: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.

Maintenance Tasks

Updating Python 3.7 runtime

Updating Python 3.6 runtime

  • Check if there are new pip packages available
    • Use the latest released image to check the outdated pip packages
    docker run --rm -it ibmfunctions/action-python-v3.6:1.17.0 sh -c "pip list --outdated"
    

Pushing new versions for runtimes

  • After the PR is merged and the master pass Travis CI, checkout master.
  • Create tag for each runtime and push upstream
git tag 3.7@<new version>
git push upstream 3.7@<new version>
  • After the image is deployed to production update the latest tag for each runtime.
git tag 3.7@latest -f
git push upstream 3.7@latest -f

License

Apache 2.0

runtime-python's People

Contributors

csantanapr avatar falkzoll avatar eweiter avatar aml2732 avatar dgrove-oss avatar dubee avatar jasonpet avatar rabbah avatar bvennam avatar dariosm avatar mdeuser avatar somaya10 avatar dependabot[bot] avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.