Welcome to nuclio-jupyter’s documentation!¶
Various utilities to work with nuclio in Jupyter notebook
Once you import nucilo
a context
object will be injected into the
notebook namesapce.
# nuclio: ignore
from nuclio import Event
event = Event(body='Hello Nuclio')
# your code goes here
In the cell you’d like to become the handler, use the magic %nuclio
handler
. If there’s a specific line you’d like to be the returned one - added
# nuclio:return
comment at the end of it.
Cells containing # nuclio: ignore
comment will be omitted in the export
process.
Now choose File/Download as/Nuclio
in Jupyter notebook (you might need to
mark the notebook as Trusted
to make this option show)
Or you can run
jupyter nbconvert --to nuclio example.ipynb
This will create example.zip
with your code wrapped in handler function also
function.yaml
nuclio configuration file.
Example¶
Will generate a zip file with handler.py
# Generated by nuclio.export.NuclioExporter on 2018-12-10 08:26:39.086907
import nuclio
def handler(context, event):
msg = 'Hello ' + str(event.body)
return msg # nuclio: return
And function.yaml
# Generated by nuclio.export.NuclioExporter on 2018-12-10 08:26:39.095522
apiVersion: nuclio.io/v1
kind: Function
metadata: {}
spec:
runtime: python:3.6
handler: handler:handler
env:
- name: API_KEY
value: '1234'
- name: NUM_JOBS
value: '2'
- name: PASSWORD
value: t0ps3cr3t
- name: USER
value: guazio
build:
commands:
- apt-get install -y libyaml-dev
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.
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