Pass startup parameters to Jupyter kernel
When we start an interactive session in the CLI with texts session we have a rich choice of options:
-h, --help show this help message and exit
-g GRAMMAR_PATH, --grammar-path GRAMMAR_PATH
path to grammar root file
-l LAUNCHPAD_FILE, --launchpad-file LAUNCHPAD_FILE
path to launchpad file
-u UUID, --uuid UUID UUID of a model
-r, --autorun run the model
-a, --async-run run in background
-d, --on-demand run on demand
-s SLEEP_TIME, --sleep-time SLEEP_TIME
sleep time for background evaluation in seconds
-q QADAPTER_FILE, --qadapter-file QADAPTER_FILE
path to default qadapter file
-f MODEL_FILE, --model-file MODEL_FILE
path to model file
-w, --ignore-warnings
do not display warnings
--no-unique-launchdir
disable unique launchdir
--enable-logging enable logging messages
--logging-level {NOTSET,DEBUG,INFO,WARNING,ERROR,CRITICAL}
logging level
--logfile LOGFILE logfile
--no-duplicate-detection
disable duplicate detection
To be able to override some default parameters when starting a new note book, we have to devise a user interface (UI) to pass these to Jupyter. Only a few of the options can be modified in the notebook using magics (see #205 (closed)): sleep time, autorun and uuid.
Passing a non-default -a, --async-run parameter is related to issue #202.
One possible UI is a GUI similar to the one based on ipywidgets used in vre-middleware. The GUI required here would be much simpler but how to pass the collected parameters to Jupyter is not clear. Maybe the mechanism is to run some custom code at startup before instantiating VMKernel class and passing the custom parameters to VMKernel.__init__ via **kwargs.
Also there should be short welcome message when creating a new notebook from the JupyterLab launcher similar like that in the texts session.
Here some spontaneous quick hits on the web:
- https://stackoverflow.com/questions/28364029/how-can-i-set-up-default-startup-commands-in-ipython-notebooks
- https://ipython.readthedocs.io/en/8.18.0/config/options/kernel.html
- https://github.com/jupyterlab/jupyterlab/issues/9374
- https://github.com/jupyterhub/jupyterhub/issues/847
- https://github.com/jupyter/notebook/issues/624
- https://github.com/jupyter-server/enterprise_gateway/issues/678
Implementation
Jupyter console
-
--log-leveland--debugaccepted by jupyter console but this has to be tested