jupyter-lmod
jupyter-lmod copied to clipboard
lmod.load from within jupyter does not behave the same as the jupyter-lmod load [aka export modules]
The jupyter-lmod interface has a button which shows the following:
Export modules Add this in a notebook to load the same modules :
await lmod.purge(force=True) await lmod.load('.....
If I understand correctly, this will fail to load python modules, as the pythonpath/ld_library_path/whatever is set on the python which is currently running, while the jupyterlab interface is "external" to this running python instance. I am not sure if I am writing in a confusing way, so I will give an example:
Ok, to reproduce:
Working example - using the sidebar interface
- use the lmod extension.
- load a module which contains python packages
- reload the kernel (otherwise the next command fails)
- in a new cell, try to import a python module (e.g.
import gym) - works.
- Then, copy the output from the "Generate python code" button, for the next experiment
Non-working example: using python code
- Start a new session
- Add in a new notebook the lmod commands from the previous example:
await lmod.purge(force=True)
await lmod.load('blablabla')
- reload the kernel, or not - no matter
- in a new cell, try to import a python module
- never works
If I understand correctly, this will fail to load python modules, as the pythonpath/ld_library_path/whatever is set on the python which is currently running, while the jupyterlab interface is "external" to this running python instance.
You are correct, although it is not related to jupyterlab interface.
The Python code generated does not interact with the JupyterLab plugin. It modifies the environment variables contained in os.environ. Child processes of the kernel will inherits these environment variables. The usefulness of this feature is fairly limited since it is not a Python API for the JupyterLab plugin, it's only the lmod api.