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

change kernel #92

Open
artttt opened this issue Apr 6, 2022 · 2 comments
Open

change kernel #92

artttt opened this issue Apr 6, 2022 · 2 comments

Comments

@artttt
Copy link

artttt commented Apr 6, 2022

I was looking for the functionality to change the running kernel from code and came across this.
https://discourse.jupyter.org/t/is-there-magic-to-restart-kernel-change-kernel/10763/2

It was suggested that a github issue could be made (and as far as i can see it never happened) for some additional features "adding an argument that allows to skip the confirmation for kernelmenu:restart and pre-specify kernel for notebook:change-kernel"

Im most interested in being able to pre-specify the kernel for notebook:change-kernel.

I had a poke around the source to see if i could work out what to do but didn't make any progress unfortunately.

@jtpio
Copy link
Owner

jtpio commented Apr 9, 2022

Thanks @artttt.

This would indeed be useful. iirc passing extra parameters should work already?

def execute(self, command_id, args=None):
args = args or {}
self.send({"func": "execute", "payload": {"id": command_id, "args": args}})

We need to check whether these two commands in JupyterLab accept such parameters.

@artttt
Copy link
Author

artttt commented Apr 10, 2022

I did a little looking at kernel changing.
looks like there are 2 commands that do the same thing notebook:change-kernel and kernelmenu:change.

They open the selectKernel dialog and as far as i can tell dont take an argument to do what we need.

Looking at the tests in jupyterlab it looks like ultimately the command that needs to be run is
await session.changeKernel({ name: differentkernelname });

my hunch is that there are 2 choices to add this functionality:

  1. a change to jupyterlab so that at least 1 of the 2 commands above has the option of taking an argument for a kernel name and skipping the selectKernel dialog if this argument is given.
  2. add code in ipylab to call changeKernel on the current session. app.sessions.current_session.change_kernel('name') or similar.

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

2 participants