Skip to content
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

Add kernel.py file containing kernel-related routines #2272

Closed
wants to merge 3 commits into from

Conversation

martinRenou
Copy link
Member

@martinRenou martinRenou commented Nov 26, 2018

We need those changes for xeus_python. We implemented widgets support, but it enforces us to mock IPython an ipykernel at different places: IPython.display.display, IPython.display.clear_output, IPython.get_ipython, ipykernel.comm.Comm. See https://github.com/QuantStack/xeus-python/blob/master/src/xinterpreter.cpp#L41.
Those changes help by putting all those imports in one place: kernel.py. So that we just need to mock ipywidgets.kernel in xeus_python.

...containing get_kernel/register_target/display/clear_output
from ._version import version_info, __version__, __protocol_version__, __jupyter_widgets_controls_version__, __jupyter_widgets_base_version__
from .widgets import *
from traitlets import link, dlink


def load_ipython_extension(ip):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the changes on the __init__.py, I didn't know what to keep, what to change, and what to remove.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After in-person discussion with Sylvain, this doesn't seem to be useful. Maybe @jasongrout you have an idea? Do you think this can be removed? Or stay as an alias for register_comm_target for backward compatibility?

Copy link
Member

@maartenbreddels maartenbreddels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the title and comments and the description of the PR, and I'd really like to understand the issue, and the solution. Maybe a video call can help, or some more context. Happy to help with the PR though!

ipywidgets/widgets/kernel.py Outdated Show resolved Hide resolved
ipywidgets/widgets/widget.py Outdated Show resolved Hide resolved
ipywidgets/widgets/widget.py Show resolved Hide resolved
@martinRenou
Copy link
Member Author

martinRenou commented Nov 29, 2018

@maartenbreddels I edited the the PR description :)

@maartenbreddels
Copy link
Member

Sorry that it wasn't clearer at first.

No worries. Starting to understand it better.

I didn't understand it was for xeus_python, now it starts to make more sense. I do think the get_ipython and get_kernel is a bit confusing. If there is a good reason to do I think some comments may help.

@martinRenou
Copy link
Member Author

The thing is that get_ipython() is used at different places in the code, and not only to retrieve get_ipython().kernel, so your solution get_kernel = lambda: get_ipython().kernel does not really work. Also I changed the name because I would like, in xeus_python, to mock ipywidgets.kernel.get_kernel and not ipywidgets.kernel.get_ipython. Because at the end it's not ipython anymore

@martinRenou martinRenou changed the title Add kernel.py file containing get_kernel/register_target/display/clear_output Add kernel.py file containing kernel-related routines Nov 29, 2018
@martinRenou martinRenou force-pushed the add_kernel_py branch 2 times, most recently from 024172c to 589f8f4 Compare November 29, 2018 13:32
@martinRenou
Copy link
Member Author

I think we can close this PR. It is a bit outdated. And IMO we should not mock ipywidgets to have it working in xeus-python, as in ipywidgets should not be a special case. I made a PR using IPython in xeus-python: jupyter-xeus/xeus-python#400, which should fix most of these issues.

We still need to mock ipykernel.comm though, as it is used by multiple libraries for using comms. We should find a nicer way to do this, but for now, mocking is our only solution.

@martinRenou martinRenou closed this Feb 9, 2021
@martinRenou martinRenou deleted the add_kernel_py branch February 9, 2021 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants