Welcome to nuclio-jupyter’s documentation!

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

# 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

_images/menu.png

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

_images/example.png

Will generate

# Generated by nuclio-jupyter exporter

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

# In[2]:
default_name = 'Dave'

# In[3]:

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

Other Notebooks

We currently don’t support Jupyter Lab, Google Colaboratory, Kaggle Notebooks and others.

You can use nuclio.print_handler_code to print the handler code and then copy&paste it to the nuclio dashboard.

_images/print_handler_code.png

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.

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

API Reference

If you are looking for information on a specific function, class, or method, this part of the documentation is for you.

Indices and tables