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

Jupyter Notebook Import with Python Extension #3385

Closed
SalChem opened this issue May 27, 2019 · 13 comments
Closed

Jupyter Notebook Import with Python Extension #3385

SalChem opened this issue May 27, 2019 · 13 comments
Assignees

Comments

@SalChem
Copy link

SalChem commented May 27, 2019

Is there a way to how to automatically set the "Jupyter notebook import" by default? so that the popup message doesn't show everytime. I could not find a way to do so.

Also, after clicking "Do not show again", I can not find a way to add "jupyter notebook import".

What's the situation on these please?

@rchiodo
Copy link
Contributor

rchiodo commented May 28, 2019

Sorry, not sure if I understand your request.

Are you asking to have all ipynb files automatically import on open? That's not a current option.

If you click the 'do not show again', you can use the command palette to import:

image

Or right click on an ipynb file from the file pane.

Note: you need to have the python extension loaded already for the menu or the command palette item to show up. That might be why you're not finding it.

In order to load the python extension you have to open a '.py' file or an 'ipynb' file first.

@greazer
Copy link
Member

greazer commented May 30, 2019

@SalChem, our plan is that when opening a notebook file, we will automatically show the last rendered version of the notebook in the interactive window. You'll be able to also import the notebook as a python file as a separate step.

We'll also surround the preview of the notebook with some sort of indication that it's a preview and not executed cells.

@rchiodo rchiodo self-assigned this May 31, 2019
@Coderx7
Copy link

Coderx7 commented Jun 4, 2019

@greazer: Would it not be much better, that upon opening the notebooks only the rendered version gets displayed by default without showing the raw contents which in 99% of the times not intended and used?
If the raw content is needed it can then be explicitly specified using a key combination, or a button!
using this, there is no need to show it in the interactive window, and it will show as a simple tab which if needs be, can then be moved into the interactive window for execution!

@rchiodo
Copy link
Contributor

rchiodo commented Jun 4, 2019

@Coderx7 can you elaborate more? Not sure what you mean by raw contents/rendered version.

Notebooks internally have the source executed and the output html/javascript that was generated.

When we open the preview, we show both the source and the html/javascript that was generated the last time the notebook was run (without executing anything again).

It looks like this:

image

@rchiodo
Copy link
Contributor

rchiodo commented Jun 4, 2019

Alternatively if you want a py file with just the source, then you would pick import.

@Coderx7
Copy link

Coderx7 commented Jun 5, 2019

Seems very promising but where can I donwload and install this preview? this would make it much easier to give feedback.

@rchiodo
Copy link
Contributor

rchiodo commented Jun 5, 2019

It's in the insider's build.

To install this you go to your extension tab and click on the ... in the upper right. Then pick install from vsix.

@Coderx7
Copy link

Coderx7 commented Jun 5, 2019

OK, please look at this screenshot :
tempsnip

This is the raw content, 99% of the times this is not intended to be viewed by the end user. I think it'd be much better not to have it shown by default as it serves no purpose. The users usually want to/intend on viewing the actual contents of an IPython notebook and not how those contents are saved internally (i.e. raw content)!
Apart from that, this wastes an IPython interactive window(tab)! which seems to me cant execute any cells (is readonly!) so why do we waste two tabs, while we can have simply have 1 tab!?
IMHO it would be a better choice, if we could show the rendered IPython notebook as a single tab(just like any other tabs (example shown below), with a pop up menu, that would let the user to see:

  1. Import ( an inplace operation )
  2. Execute ( Cells become interactive , if this isn't possible at the moment, an IPython interactive tab can open, renders the notebook and the previous tab closes ( see it as if the readonly notebook, moves into the interactive section on the right hand side )
  3. View Raw content ( this should be an inplace operation i.e. when we found out the user intends on dealing with the underlying contents, there is no need to see the visualized/rendered output so we can simply switch to the raw text in an inplace fashion)

Here is the visualization that I made :
tmpsnips3
The IPython notebook is opened as a single tab like anyothers, the page is not cluttered like before and if a user wishes to run the IPython notebook, clicking on Execute lets him just interact with any cells in this very tab. If he/she desires to have the notebook converted into the Python and run it in the IPython interactive tab on the right side panel (like in the first screenshot), he/she can click on Import .
If he is after seeing the raw content of the notebook and not the rendered output, he/she can click on the View Raw Content.
He/she can also specify a default behavior in the settings so he/she is not bothered with the popup each time they open a notebook.

@rchiodo
Copy link
Contributor

rchiodo commented Jun 5, 2019

Unfortunately there always has to be two tabs. VS Code does not let our extension be the sole editor for .ipynb files, so they always open in a json editor.

For your 'execute' option, we could add another command - Execute Notebook (or perhaps just add it into the preview UI)

@Coderx7
Copy link

Coderx7 commented Jun 6, 2019

Why is there such a limitation?
Do you have control over the extension created output (i.e the new tab( the rendered result) ) and the tab containing the source (i.e. json editor which displayes the notebooks content)?
Can you close the json editor and let the preview still be?

@rchiodo
Copy link
Contributor

rchiodo commented Jun 6, 2019

Yeah we could auto close the ipynb file. That's not a bad idea, well unless somebody actually wants to edit it. Hmm. I'll talk it over with other people to see what they think. I don't think VS Code would be happy about it though.

VS Code doesn't let extensions be the sole editor for a file because they are worried about extensions ruining the editing experience. VS Code was originally just supposed to be a text editor. You can see this when editing markdown for example. In order to see the real markdown, you have to open another tab.

@rchiodo
Copy link
Contributor

rchiodo commented Jun 6, 2019

I'm going to add your previewer idea too. Sounds like a good improvement.

@Coderx7
Copy link

Coderx7 commented Jun 6, 2019

Thanks a lot really appreciate it.
Concerning why VSCode doesnt allow such a thing, imho, Its not really a good justification/excuse, as extensions can be made to pass several integrity/user-experience(quality) checks in order to be eligible for a release. This kind of limitation hurts VSCode more than it protects it imho!
Anyway looking forward to see how it goes, fingers crossed for the best :)

@rchiodo rchiodo closed this as completed Aug 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Aug 14, 2019
@microsoft microsoft unlocked this conversation Nov 14, 2020
@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants