Skip to main content

Convert Jupyter notebook to nuclio

Project description

nuclio Jupyter Export

License

Convert Jupyter notebook to Python code that can run as nuclio handler

Installing

pip install nuclio-jupyter

Usage

When developing, import Context and Event from nucilo and use it to generate a mock context and request.

# nuclio: ignore
from nuclio import Context, Event

context = Context()
event = Event(body='Hello Nuclio')
# your code goes here

In the cell you'd like to become the handler, added the comment # nuclio:handler. If there's a specific line you'd like to be the returned one - added # nuclio:return at the end of it.

Cells containing # nuclio: ignore comment will be commented out in the export process.

Now choose File/Download as/Nuclio in Jupyter notebook

Or you can run

jupyter nbconvert --to nuclio example.ipynb

This will create example.py with your code wrapped in handler function and all cells with # nuclio: ignore commented out.

Example

Will generate

# coding: utf-8

# In[1]:
def greeting(name):
    return 'Hi ' + name + '. How are you?'

# In[2]:
default_name = 'Dave'

# In[3]:
# # nuclio:ignore
# from nuclio import Context, Event
# context = Context()
# event = Event(body=default_name)

# In[4]:
def handler(context, event):
    # nuclio:handler
    return greeting(event.body)

Try It Out

You can build a docker image and try it out

Build

$ docker build -t jupyter-nuclio .

Run

$ docker run -p 8888:8888 jupyter-nuclio

Then open your browser at http://localhost:8888 and enter the password nuclio when prompted.

Developing

We're using pipenv as package manager. To install dependencies run

$ pipenv sync -d

To run the tests run

$ pipenv run python -m pytest -v tests

Licence

Apache 2.0 (see LICENSE.txt)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nuclio-jupyter-0.1.0.tar.gz (108.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nuclio_jupyter-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file nuclio-jupyter-0.1.0.tar.gz.

File metadata

  • Download URL: nuclio-jupyter-0.1.0.tar.gz
  • Upload date:
  • Size: 108.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.0

File hashes

Hashes for nuclio-jupyter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ce834f3183d983b59f5e34d627ad4fb56bec13b0d6cd343b75250effe05c249a
MD5 3c8f2fa2e6b8d1ef4458bdcfdcb665ac
BLAKE2b-256 7761435f21a80009288262c6088d8dc00cc071954586b296dbb6f2e700427846

See more details on using hashes here.

File details

Details for the file nuclio_jupyter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nuclio_jupyter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.0

File hashes

Hashes for nuclio_jupyter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37b7ffd9a4a726aef2425d34c5bf2816afbe8a17d27e2354b2d902e4eb57adb8
MD5 2546900896d30dcf3e53ca3cfb5d67dd
BLAKE2b-256 ce5450941abfe6785a8102a752293e0bfca647cf2a6b89c8e5ffa2f49c829602

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page