-
Notifications
You must be signed in to change notification settings - Fork 73
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
Generic way for kernels to expose comms #342
Comments
Another idea. Currently, everyone expects |
I think that make sens; |
What do you mean? |
You need
to make sure So now we are clear to use |
Oh I see, it makes sense yes. Maybe something more general than Comm might be better though, because we might want to do the same for some other useful features accessible using the current |
I like the idea of having a comm package, and kernels can depend on it and register themselves as the current comm implementation. So I imagine a kernel does something like this at startup, maybe with a fallback to use ipykernel if it is importable.
Then packages can do something like:
and not have to depend on ipykernel. |
If I understand things correctly, this is roughly the pattern used in Python's asyncio package, where various packages can register event loop implementations, but people writing asyncio code don't have to know or depend on a specific implementation. |
This has been resolved https://github.com/ipython/comm |
Currently, ipywidgets is relying on ipykernel for making use of the Comms.
It would be nice to have a more generic way for libraries to access the Comm implementation of the currently running kernel. Right now, xeus-python monkey-patches ipykernel in order to inject its own Comm class.
One idea would be to use dynamic instrumentation with importlib in the kernel implementation in order to inject a fake module, let's say we name it
current_kernel
. Then libraries like ipywidgets would import the Comm implementation doing:Another idea would be to use entry points, kernel would expose their Comm implementation and other useful things through entry points. But we would need to figure out a way for libraries to know which kernel is currently running.
Those two solutions are very specific to Python though. It would be nicer to find a solution that could be expressed in the Jupyter kernel protocol and that could be implemented in any language (maybe a file-based solution?).
cc. @jasongrout @SylvainCorlay @Carreau
The text was updated successfully, but these errors were encountered: