-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility layer for IPython
/ Jupyter
globals
#6394
Comments
IPython
/ Jupyter
globalsIPython
/ Jupyter
globals
In general, I'm very positive to the idea of using retro as a place to experiment with what level of compatibility shims and new APIs would work well. It's a smaller, safer playground, and we can always promote into new core JupyterLab APIs anything deemed generic and robust enough. This seems like an excellent idea, thanks @jtpio. |
I don't really understand how JupyterLab / RetroLab extensions work so I'm not sure what this does or does not make possible, what any consequences are / what alternative approaches would be required to achieve what functionality provided by such a shim using current Jupyterlab/Retrolab API? If the proposal was to work towards a way of putting a harness around the majority of current classic extensions, or providing a clear set of rules for how you could start to migrate different patterns from classic nb extensions to JupyterLab, that would give me a path I could start trying to walk my extensions down. I also wonder what this does to the JupyterLab extension ecosystem? Would folk have to add tags to show whether their extension works only in JupyterLab, only in RetroLab, or in both? And I wonder if these API can be exposed, why were they not exposed from the start? Or if they were, why were they withdrawn? What architectural or security principles are JupyterLab puritans being asked to give up by exposing these APIs?! ;-) |
Yes this is mostly about buying us a bit more time, since we probably can't expect all extensions to migrate to JupyterLab for notebook 7. Also this issue is more about targeting simple use cases, such as
We should still actively encourage developers to make JupyterLab extensions as this is the way forward. As discussed in other places, the tooling around authoring JupyterLab extensions can still be improved so it's more welcoming to non-developers. Folks should not start making new extensions relying on
For several reasons I would say. Having |
We should probably scope this to provide some kind of compatibility with old extensions only. New API development should be done in the main JupyterLab repo, so we don't fragment the lab ecosystem with new extensions that only work in RetroLab. |
Right now, there's no 'simple' way for python code to perform actions on the currently open notebook - something that a number of projects want to do. I think we can and should expose a safe subset of actions to this, and a global object accessible from So for the otter case, instead of compatibility shims, we could instead expose something else that can be called via If needed, we can also search GitHub for code that calls |
It can definitely be implemented as an extension. In fact some folks have already implemented some kind of proxy to do that in lab (jupyterlab/jupyterlab#5660).
By default in JupyterLab? Not sure. For example these wouldn't really apply to the code consoles. |
I'm still generally However, unifying commands as a display type, and increasing the robustness of command definition e.g. jupyterlab/lumino#58 sounds lovely. A
Where the "remember" would let you update your settings. In a managed hub setting, this could be configured with |
Agree we should not support requirejs or jquery. I think the idea here was to limit the scope to what the IPython and Jupyter globals provide in the classic notebook.
And this could already be experimented with as an extension. |
Colab offers a limited API for interacting between JS and Python: https://colab.research.google.com/notebooks/snippets/advanced_outputs.ipynb. It seems like an appropriate scope for what could be offered in "Notebook 7". |
I am all in favor of at minimum providing the limited API that Collab exposes. However, Collab appears to be a version of Jupyter notebook not JLab (see Using Collab locally). To add to the discussion of why I think we should have this:
I have found the easiest way to solve the problems is to execute javascript using
It would be nice if something nearly this simple would work in JLab. I can use this to set python variables on the fly, extract data from the kernel, run a command after the notebook front end has reached an appropriate state, etc... |
There are so many threads and discussions and even platforms (Notebook/Lab/Hub) that it's hard to know what is / is not possible / planned / not-planned / under consideration at this point. So I'm just pitching my use-case to try and show how powerful these features can be if there is support for them. Use-Case83242a1c08a500395928ec786e753856.mp4ConcernI'm worried this kind of application will not be possible, or at least will need to be very contrived / hacky in future releases of Jupyter products (Notebook, Lab, Hub). What you're seeing in that video is a web application embedded leveraging FeaturesIt seems to me that two features are needed to support and improve upon this kind of "application on top of Jupyter" model:
I'm still waiting for forum response about feature 2, but it's clear from this and other threads across this and other Jupyter repos & forums that feature 1 faces some challenges in terms of continued support. Mostly those threads are closed (hopefully not forgotten) and there are others voicing support for some version of these features. The purpose of this post is just to figure out where that is headed (is seems uncertain) and what the general consensus of the maintainers currently is about this. ExtensionsMaybe these things can be done with extensions, but I haven't found any yet which do them, much less reliably across Notebook / Hub / Lab platforms. |
Linking to https://github.com/jupyterlab/richoutput-js which might help address such use cases across Jupyter frontends in a more consistent and documented manner. |
@jtpio Does this address the exposure of the Jupyter JS application & access to execute python in the notebook's kernel via javascript (such as |
@jt0dd the goal is to provide a consistent minimal API so different frontends (JupyterLab / Notebook, Colab, VS Code) can implement a specific mime renderer and give this kind of "escape hatch" to notebook authors. It's still not clear what and how globals will be accessed from the user code but the idea would indeed be to allow for manipulating UI elements or kernel states via the Again this is still very early and will be iterated on, but worth bringing here as a way to avoid bringing back globals like |
We discussed this issue with @jasongrout during JupyterCon 2023 and figured it would indeed be useful to offer some (even partial) compatibility with older classic notebook v6 extensions. Also discussed in #6307 (comment). Jason created a small repo to demo some of these: https://github.com/jasongrout/nbactions Maybe this could be iterated on and published as a separate (third-party) extension, that end users and adminstrators could add to the Jupyter install? And then be deprecated / removed in Notebook 8. Another approach would be to add more examples to https://github.com/jupyterlab/extension-examples. For example focused on migrating from Classic Notebook 6 extensions to Notebook 7. @echarles @RRosio @ericsnekbytes is that something you would be interested in working on? Thanks! |
This topic was interestingly the first question further to our Notebook 7 talk at JupyterCon. I have also discussed similar needs with @jmshea who were looking to find back in JupyterLab the ease of access to the notebook model from any javascript (not from an extension). We will discuss that and see how we can contribute. I guess the most important question is "until where do we want to go": an extension seem like a good option for that, then what API do we agree to expose ? |
@jtpio FWIW, I blogged the process I went through as a not-developer trying to port a classic notebook extension: https://blog.ouseful.info/tag/jl-extension-notes/ |
Probably it would be fine to start small like Jason did with https://github.com/jasongrout/nbactions. And then add more if needed. |
I wonder if we could do this in https://github.com/jupyter/notebook_shim - That sounds to me like a good place, any feedback on this proposal cc/ @Zsailer ? |
I think it's important to keep such extension really separate since Line 37 in 855822d
|
Linking to #170 as related. Again if such extension would exist then it would be better to keep it separate. |
Problem
Many Python libraries used in the classic notebook rely on
IPython
andJupyter
being exposed onwindow
.This makes porting extensions to JupyterLab / RetroLab a bit difficult since this is not supported anymore.
Proposed Solution
Maybe RetroLab (and only RetroLab) should provide a compat layer and expose
window.IPython
andwindow.Jupyter
. So things likeJupyter.notebook.save()
executed in a JS cell still work in RetroLab by default.An alternative for now is to use the
jupyterapp
main application onwindow
with--expose-app-in-browser
:https://github.com/jupyterlab/retrolab/blob/6ce134fa17cc87d79fca822cbb761e4c7237b879/retrolab/app.py#L191-L195
Which can be used to execute arbitrary commands:
window-jupyterapp.mp4
This can be implemented as a new extension in the retrolab repo. The extension would expose the classic notebook API, but call JupyterLab APIs internally.
Additional context
This would help with use cases like ucbds-infra/otter-grader#448
Linking to the custom front-end extension documentation for reference: https://jupyter-notebook.readthedocs.io/en/stable/extending/frontend_extensions.html
cc @yuvipanda @davidwagner @fperez @tonyfast @psychemedia
The text was updated successfully, but these errors were encountered: