Closed marscher closed 1 year ago
I think this is twofold:
first, this https://github.com/BAMWelDX/weldx/blob/ac3eda4a4ef015e4d34767a0b7db2f3c9e22182a/weldx/asdf/file.py#L918-L922 should really be
def _ipython_display_(self):
# this will be called in Jupyter Lab, but not in a plain notebook.
from IPython.core.display import display
display(self.header(use_widgets=True, _interactive=_is_jupyterlab_session()))
unfortunately, the current _is_jupyterlab_session()
doesn't really work (reliably), at least not on the JupyterHub install
I haven't really found a nice way to implement _is_jupyterlab_session()
correctly
I think there is no correct way to implement this jlab session detection reliably, because in theory there can be arbitrary frontends (historically). Of course right now there is only jlab or jupyter notebook (the later has multiple guis).
We could monkey patch the method for Sphinx to force _interactive to be false. Or set an environment variable within the Sphinx build which can the be checked in the implementation. Both solutions are not elegant, but they'd do the job.
I like the monkey patching approach you mentioned, that shouldn't be to difficult I hope?
It is not possible to patch this via the Sphinx config, because the kernel manager involved in executing the notebooks is a separate process which does not ever import this config.
The current implementation also renders the YAML html output instead of the JupyterLab JSON implementation on the JupyterHub for me @marscher
But I think it is fine to leave it for now
On Windows? On Linux I gave it a shot and it used the widgets correctly.
On Windows? On Linux I gave it a shot and it used the widgets correctly.
Interesting, I was logging into the Lab-JupyterHub from Windows for testing
The heuristic checking if a jupyter lab server is involved just inspects the names of the parent processes. If the littlest jupyter hub server has a different naming pattern than the "normal" console based jupyter lab startup, this won't work.
This can only be shown in a Jupyter lab environment. So the selection of the output should be made aware, that it is contained in a Sphinx/non-interactive session in order to avoid this.