Skip to main content

Convert Jupyter notebook to nuclio

Project description

nuclio Jupyter Export


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


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 with your code wrapped in handler function and all cells with # nuclio: ignore commented out.


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


$ docker build -t jupyter-nuclio .


$ docker run -p 8888:8888 jupyter-nuclio

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


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


Apache 2.0 (see LICENSE.txt)

Project details

Release history Release notifications

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
nuclio-0.1.0-py3.7.egg (11.4 kB) Copy SHA256 hash SHA256 Egg 3.7
nuclio-0.1.0-py3-none-any.whl (7.0 kB) Copy SHA256 hash SHA256 Wheel py3
nuclio-0.1.0.tar.gz (108.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page