From 4f9b36b042ad58eb0569c5b58623bdacb33b94c4 Mon Sep 17 00:00:00 2001 From: Soam Vasani Date: Wed, 18 Jan 2017 16:53:03 -0800 Subject: [PATCH] Add README to python env --- environments/python3/README.md | 44 ++++++++++++++++++++++++++++++++++ environments/python3/server.py | 9 ++++--- 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 environments/python3/README.md diff --git a/environments/python3/README.md b/environments/python3/README.md new file mode 100644 index 00000000..7b6c318a --- /dev/null +++ b/environments/python3/README.md @@ -0,0 +1,44 @@ +# Fission: Python Environment + +This is the Python environment for Fission. + +It's a Docker image containing a Python 3.5 runtime, along with a +dynamic loader. A few common dependencies are included in the +requirements.txt file. + +## Customizing this image + +Most commonly you might want to add package dependencies. Edit +requirements.txt to add what you need, and rebuild this image. + +You also may want to customize what's available to the function in its +context. You can do this by editing server.py. + +## Rebuilding and pushing the image + +You'll need access to a Docker registry to push the image: you can +sign up for Docker hub at hub.docker.com, or use registries from +gcr.io, quay.io, etc. Let's assume you're using a docker hub account +called USER. Build and push the image to the the registry: + +``` + docker build -t USER/python-env . && docker push USER/python-env +``` + +## Using the image in fission + +You can add this customized image to fission with "fission env +create": + +``` + fission env create --name python --image USER/python-env +``` + +Or, if you already have an environment, you can update its image: + +``` + fission env update --name python --image USER/python-env +``` + +After this, fission functions that have the env parmeter set to the +same environment name as this command will use this environment. diff --git a/environments/python3/server.py b/environments/python3/server.py index e2cd798c..5c64a79a 100644 --- a/environments/python3/server.py +++ b/environments/python3/server.py @@ -4,9 +4,7 @@ import logging import sys import imp -from flask import Flask -from flask import request -from flask import abort +from flask import Flask, request, abort, g app = Flask(__name__) @@ -25,6 +23,11 @@ def f(): if userfunc == None: print("Generic container: no requests supported") abort(500) + # + # If you want to pass something to the function, you can add it to 'g': + # g.myKey = myValue + # And the user func can then access that (after doing a "from flask import g"). + # return userfunc() #