openfaas-incubator / python3-debian

Template for Python3 on Debian for data-science / compiled pip modules
MIT License
4 stars 10 forks source link

Update Python3 handler to return result #3

Closed roncrivera closed 5 years ago

roncrivera commented 5 years ago

The handler should return instead of printing result to match the Python3 example in the openfaas/templates repo.

Signed-off-by: Ron Rivera roncrivera@gmail.com

roncrivera commented 5 years ago

This looks good @roncrivera

How was it tested?

  1. Created sample function from my local python3-debian template that includes the changes to {handler,index}.py
    
    $ faas-cli new python3-debian --lang python3-debian --prefix riverron
    Folder: python3-debian created.
    ___                   _____           ____
    / _ \ _ __   ___ _ __ |  ___|_ _  __ _/ ___|
    | | | | '_ \ / _ \ '_ \| |_ / _` |/ _` \___ \
    | |_| | |_) |  __/ | | |  _| (_| | (_| |___) |
    \___/| .__/ \___|_| |_|_|  \__,_|\__,_|____/
      |_|

Function created in folder: python3-debian Stack file written: python3-debian.yml


2. Built, published and deployed stack the usual way

$ faas-cli build [0] > Building python3-debian. Clearing temporary build folder: ./build/python3-debian/ Preparing ./python3-debian/ ./build/python3-debian/function Building: riverron/python3-debian:latest with python3-debian template. Please wait.. Sending build context to Docker daemon 7.68kB Step 1/17 : FROM python:3 ---> 7c5fd2af3815 Step 2/17 : RUN curl -sSL https://github.com/openfaas/faas/releases/download/0.9.6/fwatchdog > /usr/bin/fwatchdog && chmod +x /usr/bin/fwatchdog [...] [...] [...]

$ faas-cli deploy Deploying: python3-debian.

Deployed. 202 Accepted. URL: http://192.168.99.100:31112/function/python3-debian


3. Invoked the sample function

$ echo -n 'Hello OpenFaaS!' | faas-cli invoke python3-debian Hello OpenFaaS! $ faas-cli list Function Invocations Replicas python3-debian 3 1



Please let me know if the above test is enough or if there's additional test that needs to be done.

Thanks.
alexellis commented 5 years ago

LGTM