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 connect to an existing kernel? #118

Open
BlkPingu opened this issue Feb 24, 2021 · 9 comments
Open

How to connect to an existing kernel? #118

BlkPingu opened this issue Feb 24, 2021 · 9 comments
Labels

Comments

@BlkPingu
Copy link

How do I start a kernel from an existing notebook? I'm getting asked for "connection info" what is this exactly supposed to be?

@sschuhmann
Copy link
Collaborator

The steps to connect a file to a kernel are:

  1. Open a python file in sublime
  2. Run command "Helium Connect Kernel"
  3. Choose "New Kernel" and the python version
  4. Provide a name for the Kernel connection

Is Sublime Text able to find Jupyter? Are you using Anaconda for installing Jupyter?

@BlkPingu
Copy link
Author

BlkPingu commented Feb 28, 2021

Steps are working until I enter the json with the connection info. I can’t seem to be able open an existing notebook. All I get, even when connected to a kernel, is a blank document. I can’t open a Notebook as I seem to be able to render it in it’s raw json form. Instead, connecting to a kernel gives me a blank document.

To clarify, after entering the connection info json, in sublime, I expected it to open the notebook associated with this kernel.

What it actually does, is give me a blank document.

I have installed everything with pip/homebrew

@sschuhmann
Copy link
Collaborator

Helium is only connecting to the kernel for code execution and is not able to fetch the notebook/notebooks which are connected to a kernel. However, I'm not sure if this is even possible, since I'm not aware of the kernel does hold a file association. Also multiple files could be connected to one kernel, leading to the problem on how to determine which file to load or how to merge.

Does any other software you know provide such a feature?

@BlkPingu
Copy link
Author

BlkPingu commented Mar 2, 2021

Okay what you’re basically saying is, sublime can connect to an existing kernel and then I can use it to execute my custom files that are totally different from the ipynb files. Got it. I can’t open ipynb files and work on them with sublime.

Yes, VSCode let’s you open ipynb files and work with them if you install the right extensions. It’s basically exactly the same like a notebook, except it’s in VSCode. They added extensive support fairly recently and it’s extremely fine

@sschuhmann
Copy link
Collaborator

Yes, this is the current behavior. Converting ipynb files into the Python file format Helium supports is on our wishlist, but I haven't been able to work on that feature yet. This way it would be possible to

  1. Convert an ipynb file to a python file
  2. Open in Helium and execute code
  3. If needed convert it back to a ipynb file

Is VSCode able to load the file content from a kernel connection or are you opening the file with vscode?

@BlkPingu
Copy link
Author

BlkPingu commented Mar 2, 2021

I’m opening the file with VSCode and it starts a new kernel for it as far as I can tell. I encourage you to take a look at how it works, as it’s fully open source. It’s just effortlessly good and by far the best way to work on ipynb I have ever seen

@ngr-t
Copy link
Collaborator

ngr-t commented Mar 3, 2021

Maybe it is possible.
Please follow "3. Connect to a kernel already running under some other Jupyter app (such as Notebook)" in README.

  1. Get connection info of the kernel. The way to get connection info differ among kernels, see the doc of each kernel (in ipython kernel, you can get it by %connect_info magic.)
  2. Run Helium: connect kernel command.
  3. Choose New kernel.
  4. Choose (Enter connection info).
  5. Enter the connection info (Helium accepts a path or connection info itself).

I think this is what @BlkPingu want, isn't?

@sschuhmann
Copy link
Collaborator

As far as I understood, the first proposal was to

  1. Connected to an existing kernel
  2. Load the notebook associated with this kernel into Helium

This would assume that a kernel has copy/reference to the associated file and I'm not aware of any such functionality. The last proposal was to

  1. Open an ipynb file
  2. Start a kernel associated with this file

This would include to support ipynb file structure and conversion layer to present it with the ST minhtml methods. This would be possible, but would not look like the implementation of VSCode.

@ngr-t
Copy link
Collaborator

ngr-t commented Mar 3, 2021

Sorry that I misunderstood the point.
Connecting to an existing kernel is not the function to load a notebook, just connect to the kernel behind it. You can use the interpreter running behind the Notebook, that's all, at least for now.

Maybe we can

  • load the notebook itself and show it in Sublime window (as @sschuhmann mentioned above)
  • follow the history held in the kernel and show them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants