vscodeJupyter icon indicating copy to clipboard operation
vscodeJupyter copied to clipboard

Jupyter/IPython REPL enhancement

Open DonJayamanne opened this issue 7 years ago • 19 comments

From @gandhis1 on October 20, 2016 1:19

Currently, the Jupyter implementation provides results in a separate pane, but with limited visual cues on the relation of code and outputs.

For instance, Atom's Hydrogen - the user is running a specific code block at a time, and the results show up right below the code. If given code does not produce anything, nothing shows up, but the user is aware that it ran. Right now, if I run "Run Selection/Line" on code that does nothing, e.g. imports, there is no visual feedback to see that it ran.

image

Another alternative/example would be the PyQT IPython REPL, which has a different layout, but still the same core idea:

image

I think one of the big use cases for Jupyter is going to be interactive coding, which isn't nearly as seamless right now as it could be.

Copied from original issue: DonJayamanne/pythonVSCode#401

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

@gandhis1 , we're looking at implementing the first solution. I.e. displaying results inline.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @gandhis1 on October 20, 2016 1:24

That sounds great! Looking forward to it...I do a lot of "interactive" coding, from which things don't necessarily align themselves neatly into the concept of a cell. I'd be using a lot of "Run Selection", and modifying code on-the-fly.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

@gandhis1 , got it thanks. Just out of curiosity, when you say "interactive" coding, do you mean Hydrogen or a IPython REPL.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @gandhis1 on October 20, 2016 1:32

Currently I use something more along the lines of an IPython REPL (IPython terminal in VSCode or IPython QT in PTVS), but for my usage I don't really see that much of a difference vs. Hydrogen. Hydrogen is just in-lined and lacks IPython magic functions / features. But the core idea is interactively executing code...which both accomplish.

I'm probably more keen on seeing Hydrogen happening than an IPython REPL, since as I mentioned, one can do the latter anyway through the terminal (it just isn't that well-integrated).

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

@gandhis1

it just isn't that well-integrated

What isn't integrated? Sorry , but I'm trying to understand what features are crucial here (when building the functionality into my extension). Is it the fact that the images are non interactive, or there's a lack of intellisense? Thanks.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @gandhis1 on October 20, 2016 1:44

Well mainly just the fact that I have to highlight code, copy, then click on the terminal window to activate it, paste it in, press enter. It can become tedious. In PTVS, I highlight code, press CTRL+E+E, and it runs in the IPython REPL. Also, the VS Code terminal window has limited capability for "text-editing manuevers", e.g highlighting text with your keyboard is not easy, for instance.

The way I see it, there are 2 paths:

  • Use an IPython REPL and integrate it a bit more closely with the text-editor. The issue I see with this is this seems somewhat redundant - when does one use the Jupyter notebook functionality vs. this? Bit of a grey area.
  • Implement a hydrogen-esque solution, which extends the existing Jupyter notebook functionality. Downsides include not having IPython magic functions and auto-completion. Upsides include having 1 feature serving two purposes, (1) a REPL, and (2) a cell-based notebook.

Maybe a good idea to get more opinions, I'm sure others have other, perhaps broader, experiences with this.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @Darktex on October 21, 2016 2:33

+1 on providing some sort of feedback back to the user.

Also, I like Hydrogen's behavior better for Ctrl + Alt + Enter, which is Run Selection and Advance instead of Run Selection only. It helps with the visual feedback and allows you to quickly rerun a bunch of different commands simply by spamming Enter while keeping Ctrl and Alt pressed. Hydrogen has Run only on Ctrl Shift Enter by default.

More than that, Run and Advance is not working for me. It does run the line, but it doesn't advance.

One more feature that Hydrogen has that I like a lot is that it's cleverer with multiline code. If you have a N-lines expression, you can use Ctrl Alt Enter on the first line of the expression, and it will evaluate the whole thing, with the cursor going down N+1 lines instead of just 1 line. Currently, to do the same I'd have to select everything with my mouse, which is slower and breaks my flow.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @gandhis1 on October 21, 2016 2:57

And +1 on your comments. It makes a whole lot more sense for the command to advance ahead. If I can execute an entire Python script without ever leaving the editor and pressing anything other than 1 keyboard shortcut, that would be fantastic.

Thinking about this, perhaps the keyboard shortcut should be able to be "smart", i.e.:

  • If the cursor is located in a cell, execute the entire cell, and advance to the code after the cell.
  • If the cursor is not located in a cell, and no text is selected, execute the entire statement (edit: which may or may not be multiple lines), and move to the next statement.
  • If the cursor is not located in a cell, and text is selected, execute the selected text, and move to code immediately following the selection.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @Darktex on October 21, 2016 17:19

I think @gandhis1 's proposal would be great! One more thing that I'd specify is that in bulletpoint 2, you'd want to execute the whole instruction, not the whole line (see my comment on handling multiline instructions)

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @auphofBSF on October 26, 2016 2:38

Being able to select and Ctrl C copy part of a result block would be great, Hydrogen only allows "copy to clipboard" and "open in Editor" image

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

@auphofBSF , not sure if this can be implemented. The current design of inline widgets in VS Code (in early development) doesn't support this. Will chase this up though.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @gandhis1 on October 27, 2016 17:35

Depends on how long you intend to maintain the current output window format, but it would be great if "Append Results" meant auto-scrolling to the most recent result as well.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

Append result does scroll to the last result

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @gandhis1 on October 27, 2016 22:56

I've had this behave inconsistently, will see if I can come up with a test case to show this.

Update: I don't get it to auto-scroll at all, to be honest. In any context.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

From @gandhis1 on November 3, 2016 23:11

Hey @DonJayamanne, do you actually get the window to scroll to the last result, including when you print a Pandas dataframe? My window does not scroll to the last result at all, in any context.

For example, the screenshot below, with append turned on, you can see the scroll bar only has scrolled to where I manually scrolled to and no further. There are more dataframes below the one you see.

untitled

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

@gandhis1 Will look into this. Works at my end for Mac. Haven't tried with dataframes though. Only tried with plain text, images and similar.

DonJayamanne avatar Mar 09 '17 14:03 DonJayamanne

As a data scientist I prefer the spyder repl way over hydrogen. I don't see how hydrogen brings more too the table than what is already provided in the normal Jupyter notebook. If something similar to the spyder repl was added I would ditch spyder and only use vscode.

bordingj avatar Jun 27 '17 06:06 bordingj

For testing code, the inline results feature (like in Hydrogen) would be greatly appreciated at least as an option. For data science / more hardcore "interactive" use cases, I already have a REPL open (qtconsole, ptipython, take your pick etc) with key bindings to send and execute code from editor - basically replicates Spyder but better customization.

ghost avatar Jul 17 '17 23:07 ghost

The more I use this extension the more I prefer it over in-line printing as in Hydrogen. The code stays clean and the ability to view past results is incredibly handy.

What I would suggest is to keep expanding and updating the current implementation. Couple of tweaks:

  1. Provide ability to connect to the kernel via the terminal as in hydrogen-launcher. It's convenient to quickly check some functions in the console rather than having to write them in the editor and running them.

  2. Give in line feedback on which part of code is being run atm and a check mark when it is completed. Quite like hydrogen but I would also highlight the lines that are being evaluated. Some tasks take a lot of time.

  3. Perhaps change the color of 'Run Cell' after it was clicked and completed or some sort of feedback to distinguish which cell were run.

  4. I already suggested it before but a bigger separation between individual output results would be great. I have also noticed that you added the ability to copy the code that was used to generate the results or selectively clean the output - great idea!

  5. Lastly, although this might be too tricky, is to have another panel with summary of variables and ability to view them (whole data frames etc) - same as in RStudio, yhat Rodeo or jupyterlab. I quite miss this option. Perhaps another tab next to Results one if it cannot be fitted together?

Overall, I would think it's better to develop towards a product such a RStudio - JupterLab is going in the same direction as well.

dask-jupyterlab-1

Keep up the great work.

ghost avatar Aug 10 '17 03:08 ghost