-
Notifications
You must be signed in to change notification settings - Fork 13
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
Draft: Add bi-directional comms and run operations in tasks #135
Conversation
@jtpio - There's a lot of changes in this code, but the jist of it is that I've adjusted it from a Python perspective to provide the features that I've been looking for with an app that can run in Jupyterlab (including autostart). I've spent more time than I intended on this (pretty much all of January), but it has help aid in my learning of JS (I expect some of it is a bit sloppy). If you could find some to to have a look through the notebooks would be appreciated. Note the major requirements are:
|
Thanks @fleming79 for all the work on this! It looks like a nice feature indeed, will have a look soon 👍
The JupyterLab and ipywidgets requirements would likely be fine. For requiring Python 3.11, maybe there could be a fallback mode so |
I had a look at supporting older versions. With a few changes was able to get it to work with 3.10. But anything older than that require re-writing/removing of type hints. |
Regarding creating a new session without a notebook. I'm wondering if the new session should be based around a document... Currently, the function It'd be better to use
|
Thanks @fleming79 for working on this! And sorry for the delay, I'll try to have a look soon. |
@jtpio - no problem. I've been learning as I go and using it for my own purposes. As an aside, I was looking at your PR for Ipywidgets jupyter-widgets/ipywidgets#3004 from 2020 (which is still open) and saw a bit of a discussion having a widgetManager on a per-kernel basis.
I think this concept is worth pursuing and am currently investigating how difficult it may be to implement. It would solve the issue in this PR associated with needing to create a WidgetManager and manually register widgetmodels, and the problem of widget comms shutting down when the notebook is closed. |
I noticed that jupyter-widgets/ipywidgets#3004 has now been merged - that's great! |
// For the moment we'll use a dummy session.
// In future it might be better to support a document...
const session = sessionContext.session;
const context = {};
(context as any)['sessionContext'] = sessionContext;
(context as any)['saveState'] = new Signal({});
(context as any).saveState.connect(() => {
null;
});
registerWidgetManager(context as any, rendermime, [] as any); |
The concept of a single widget manager per kernel looks very promising, there is a draft PR open here: single widget manager per kernel PR. This enables creating a session (new kernel) that has it's own comms and widgets enabled. Its usage is demonstrated in A launcherAn example appWith the console openedAttachmentsExtract and install with pip. Install jupyterlab_widgets first. |
@jtpio - Just wondering if you would be able to find some time to try this PR? |
This PR has many breaking changes so will need to be a major release.
Almost all interaction between Python and the Frontend is run as a task using custom messages. Should an error occur in the Frontend the error will be raised in task. This makes it possible to control the sequence of operations and respond to errors as they occur.
Some Python classes, such as
JupyterFrontEnd
, are now singleton instances (per kernel) where it makes sense.Feature summary
Connection
to link from Python to a disposable in the Frontend. The close method on the Python object has an option to dispose the object in the Frontend. The disposable object is specified as the base providing direct access to the object.ShellConnection
is provided to the Lumino widget that is added to the shell.evaluate
(python code).Notes
concurrent
kernel that partially works.