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

How to detect xeus-python? #470

Open
krey opened this issue Aug 31, 2021 · 5 comments
Open

How to detect xeus-python? #470

krey opened this issue Aug 31, 2021 · 5 comments

Comments

@krey
Copy link

krey commented Aug 31, 2021

How would you detect from code running in a notebook whether it is running in a xeus kernel?

To detect ipykernel, you could do:

'IPKernelApp' in sys.modules['IPython'].get_ipython().config

Is there a xeus analogue?

@martinRenou
Copy link
Member

You could do something like:

sys.modules['IPython'].get_ipython().__class__.__name__ == 'XPythonShell'

@martinRenou
Copy link
Member

It's a bit weak though. As this class is not part of the API, so we cannot ensure the name of the class will remain the same.

@JohanMabille
Copy link
Member

I think we should add a config attribute to the XPythonShell class to be consistent xwith IPykernel.

@JohanMabille JohanMabille reopened this Aug 31, 2021
@martinRenou
Copy link
Member

This config attribute seems to come from Traitlets. And our shell already has it, but it's empty. We need to understand how it gets populated.

I see some references to IPKernelApp in ipython directly (https://github.com/ipython/ipython/search?q=ipkernelapp), I just hope it doesn't come from there...

@JohanMabille
Copy link
Member

From what I see on my machine, it only contains the path to the connection file. I guess there might be more complex configurations, but we don't have to replicate IPykernel behavior, as long as we provide a similar way to identify whether the kernel is IPykernel or xeus-python.

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

No branches or pull requests

3 participants