%nuclio magic

When you import the nuclio module, a new %nuclio magic command will be added to IPython/Jupyter.

Overview

In [1]: %nuclio help Overview
Show help on command. Available commands:
 - cmd: Run a command, add it to "build
 - config: Set function configuration value
 - deploy: Deploy function
 - env: Set environment variable
 - env_file: Set environment from file(s)
 - export: Export notebook
 - handler: Mark this cell as handler function
 - help: Print help on command
 - verbose: Toggle verbose mode

cmd

In [1]: %nuclio help cmd
Run a command, add it to "build.Commands" in exported configuration.

 Examples:
 In [1]: %nuclio cmd pip install chardet==1.0.1

 In [2]: %%nuclio cmd
 ...: apt-get install -y libyaml-dev
 ...: pip install pyyaml==3.13

 If you'd like to only to add the instructions to function.yaml without
 running it locally, use the '--config-only' or '-c' flag

 In [3]: %nuclio cmd --config-only apt-get install -y libyaml-dev

config

In [1]: %nuclio help config
Set function configuration value. Values need to be Python literals (1,
 "debug", 3.3 ...). You can use += to append values to a list

 Example:
 In [1] %nuclio config spec.maxReplicas = 5
 In [2]: %%nuclio config
 ...: spec.maxReplicas = 5
 ...: spec.runtime = "python2.7"
 ...: build.commands +=  "apk --update --no-cache add ca-certificates"
 ...:

deploy

In [1]: %nuclio help deploy
Deploy function .

 Examples:
 In [1]: %nuclio deploy
 %nuclio: function deployed

 In [2] %nuclio deploy --dashboard-url http://localhost:8080
 %nuclio: function deployed

 In [3] %nuclio deploy --project faces
 %nuclio: function deployed

env

In [1]: %nuclio help env
Set environment variable. Will update "spec.env" in configuration.

 Examples:
 In [1]: %nuclio env USER=iguzaio
 %nuclio: setting 'iguazio' environment variable

 In [2]: %%nuclio env
 ...: USER=iguazio
 ...: PASSWORD=t0ps3cr3t
 ...:
 ...:
 %nuclio: setting 'USER' environment variable
 %nuclio: setting 'PASSWORD' environment variable

env_file

In [1]: %nuclio help env_file
Set environment from file(s). Will update "spec.env" in configuration.

 Examples:
 In [1]: %nuclio env_file env.yml

 In [2]: %%nuclio env_file
 ...: env.yml
 ...: dev-env.yml

export

In [1]: %nuclio help export
Export notebook. Possible options are:

 --output-dir path
     Output directory path
 --notebook path
     Path to notebook file
 --handler-name name
     Name of handler
 --handler-file path
     Path to handler code (Python file)

 Example:
 In [1] %nuclio export
 Notebook exported to handler at '/tmp/nuclio-handler-99'
 In [2] %nuclio export --output-dir /tmp/handler
 Notebook exported to handler at '/tmp/handler'
 In [3] %nuclio export --notebook /path/to/notebook.ipynb
 Notebook exported to handler at '/tmp/nuclio-handler-29803'
 In [4] %nuclio export --handler-name faces
 Notebook exported to handler at '/tmp/nuclio-handler-29804'
 In [5] %nuclio export --handler-file /tmp/faces.py
 Notebook exported to handler at '/tmp/nuclio-handler-29805'

handler

In [1]: %nuclio help handler
Mark this cell as handler function. You can give optional name

 %%nuclio handler
 ctx.logger.info('handler called')
 # nuclio:return
 'Hello ' + event.body

 Will become

 def handler(context, event):
     ctx.logger.info('handler called')
     # nuclio:return
     return 'Hello ' + event.body

help

In [1]: %nuclio help help
Print help on command.

 Example:
 In [1]: %nuclio help
 Available commands:
 - env
 - env_file
 ...

 In [2]: %nuclio help env
 ... (verbose env)

verbose

In [1]: %nuclio help verbose
Toggle verbose mode.

 Example:
 In [1]: %nuclio verobose
 %nuclio: verbose off
 In [2]: %nuclio verobose
 %nuclio: verbose on