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

Explore using the interactive window as a console for notebook kernels #6765

Closed
joyceerhl opened this issue Jul 22, 2021 · 8 comments
Closed
Assignees
Labels
feature-request Request for new features or functionality interactive-window Impacts interactive window

Comments

@joyceerhl
Copy link
Contributor

joyceerhl commented Jul 22, 2021

From discussion with @greazer @rchiodo @claudiaregio @rebornix

Existing feature requests:

Proposed experience:

  • Command contributed to notebook/cell/title to open interactive window connected to same kernel
  • Command contributed to interactive/cell/title to paste code back into notebook
  • Kernel picker to be hidden
  • Sys info cell to indicate the notebook association
  • Context keys to hide interactive window specific functionality
  • Title should say 'Scratchpad'
  • Should the interactive window immediately receive focus when created?

Bare-bones prototype:
recording (7)

Open questions

Engineering notes:

  • Summary: Jupyter extension needs to refactor our VSCodeNotebookController wrapper, IKernel, and the cell execution codepath to allow
    • an IKernel that is currently mapped to a jupyter-notebook controller which has been selected for a given jupyter-notebook NotebookDocument
    • to be reused for an interactive controller that is selected for a given interactive NotebookDocument
  • Current state/background
    • Currently vscode.NotebookControllers are per-notebookType, so to get our kernels to show up for interactive windows, each of our kernels is registered twice with VS Code--once for the jupyter-notebook notebookType and once for the interactive notebookType
    • Our code currently assumes a 1-1 relationship between a VS Code NotebookController and our internal IKernel objects, i.e. controller is passed into IKernel constructor and then passed all the way down through the constructors of KernelExecution, CellExecutionQueue, CellExecution etc. in order to create the notebook cell execution task
    • Controllers can only create execution tasks for the NotebookDocument that they are currently associated with in VS Code
    • Our code currently also starts a new kernel for each new NotebookDocument in kernelProvider.getOrCreate
    • Interactive window needs to be passed a controller ID at creation to pick up the right controller (alternative is notebook.selectKernel or similar after the window is created, but we've discussed this and decided not to do it). NotebookDocument is returned from interactive.open, so given the jupyter-notebook controller currently selected for a Jupyter notebook, we need to find the matching interactive controller that we told VS Code about, and make sure that the underlying kernel is reused
    • Note, this also means that if we want arbitrary notebooks to be able to start an interactive session, then all those extensions must ensure that they return the same instance for jupyter-notebook and interactive notebookTypes (not guaranteed to work OOB)
@greazer greazer added this to the July 2021 Release milestone Jul 22, 2021
@rebornix rebornix modified the milestones: July 2021, August 2021 Jul 28, 2021
@greazer greazer added the interactive-window Impacts interactive window label Aug 3, 2021
@greazer greazer removed this from the August 2021 milestone Aug 9, 2021
@ishipachev
Copy link

I would be glad to see this implemented.
My workflow around this feature would be like this:

  • write some code in a notebook
  • get some intermediate results and variables
  • experiment with some variables or functions in console without creating additional code cell and cleaning it after
  • put some outcomes of this experiments into notebook

Right now I can do it only in Interactive mode (with blocks starting with # %%), but this approach lacks of visual outputs I can have in notebooks.

@Rchatru
Copy link

Rchatru commented Oct 7, 2021

I also join the petition. I recently switched from JupyterLab to VSCode, and this is an especially useful feature that makes it easier the daily work. It is quite common that at a certain moment we want to do some test with the variables, etc. in the notebook, and it is a bit clumsy to have to create new cells and then delete them again, especially when it is something that can be done in seconds from the interactive shell.

I think that all of us who work often with Jupyter Notebooks, would be very grateful if you could add this function.

@thehappycheese
Copy link

Yes please this is what I need! :)

@philffm
Copy link

philffm commented Jan 21, 2022

Cheers! Seems like I managed to find a workaround. (can use the Jupyter Notebook variables in the interactive window now. A bit of a process but imho worth it :D)

The process

  1. Command + Shift + P
  2. Jupyter: Create Interactive Window
  3. Copy URL of Remote Jupyter Session
  4. again: Command + Shift + P -> Jupyter: Specify local or remote Jupyter server for connections
  5. Paste URL of Remote Jupyter Session
  6. In the interactive window select the current session (remote)
  7. That's it! The active variables from the Jupyter Notebook should now available in the interactive console (if not, try running it again)

@Rchatru
Copy link

Rchatru commented Jan 21, 2022

I have to try this, if it works it would be really wonderful. Thank you very much for sharing.

@notuntoward
Copy link

Yes, quick and easy like how Jupyterlab does its console. Or Rstudio, or Matlab, or Spyder.

I'm trying out vscode -- and like it for features other than this -- but I'm really missing this fairly standard type of console.

@vttrifonov
Copy link

@philffm Thats cool! Just what I needed.

Now if we can do the same dance but without having to start the Jupyter server separately... All within VSCode, please! I mean, sometimes it is definitely nice to have the remote server option but dealing with VSCode only will make life so easy.

@amunger
Copy link
Contributor

amunger commented Dec 6, 2022

duplicate of #4573

@amunger amunger closed this as completed Dec 6, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality interactive-window Impacts interactive window
Projects
None yet
Development

No branches or pull requests