Running Jupyter Lab / Notebooks

The following commands are performed by the acme.joe user.

First, create a custom Dockerfile that includes (at least) python:

FROM python:3.7

RUN pip install jupyterlab
CMD jupyter lab --ip=0.0.0.0 --port=8080 --no-browser \
    --LabApp.token='' \
    --LabApp.custom_display_url=https://${EAI_JOB_ID}.job.console.elementai.com \
    --LabApp.allow_remote_access=True \
    --LabApp.allow_origin='*' \
    --LabApp.disable_check_xsrf=True

Warning

Albeit insecure in itself, this image can safely be run inside Toolkit because Toolkit takes care of the security features. This image should not be run or used anywhere else.

Build, tag and push the image:

$ export IMAGE=registry.console.elementai.com/acme.joe/jupyterlab
$ docker build -t $IMAGE .
$ docker push $IMAGE

Note that even if security features are disabled, usual toolkit security is in effect. So to run a Jupyter Lab environment using acme.joe.workspace as the workspace, simply submit a job with the following:

$ eai job submit --image $IMAGE --data acme.joe.workspace:/workspace
id                                   state   name created              command runs.exitCode
f52f7cd3-174f-48e8-a30a-8913e63cd68a QUEUING      2019-12-06T21:13:14Z []      -
$ eai job logs -f
[I 21:13:19.505 LabApp] Writing notebook server cookie secret to /tmp/.local/share/jupyter/runtime/notebook_cookie_secret
[W 21:13:19.655 LabApp] All authentication is disabled.  Anyone who can connect to this server will be able to run code.
[I 21:13:19.660 LabApp] JupyterLab extension loaded from /opt/conda/lib/python3.6/site-packages/jupyterlab
[I 21:13:19.660 LabApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
[I 21:13:19.662 LabApp] Serving notebooks from local directory: /workspace
[I 21:13:19.662 LabApp] The Jupyter Notebook is running at:
[I 21:13:19.662 LabApp] https://f52f7cd3-174f-48e8-a30a-8913e63cd68a.job.console.elementai.com/
[I 21:13:19.662 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

Once running, use the job ID to connect yourself to the web interface using your browser. For example:

In this example, the mounted dataset can be found at /workspace.

Note

Control-C will not stop the server. To terminate the server, you need to kill the job itself:

$ eai job kill f52f7cd3-174f-48e8-a30a-8913e63cd68a