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

Importing a jupyter notebook should show the last output #3403

Closed
jianboy opened this issue May 18, 2019 · 23 comments
Closed

Importing a jupyter notebook should show the last output #3403

jianboy opened this issue May 18, 2019 · 23 comments
Assignees

Comments

@jianboy
Copy link

jianboy commented May 18, 2019

Environment data

  • VS Code version: 1.31.1
  • Extension version (available under the Extensions sidebar): 2019.3.6558
  • OS and version: windows10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda

Expected behaviour

jupyter-notebook

Actual behaviour

14

Steps to reproduce:

  1. XXX

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

XXX
@rchiodo
Copy link
Contributor

rchiodo commented May 20, 2019

Can you paste the code that's causing the problem? Something in the imported code is invalid python.

@rchiodo rchiodo changed the title Can not render as HTML in the interactive window alongside code and output Importing a jupyter notebook is not generating correct code May 20, 2019
@rchiodo
Copy link
Contributor

rchiodo commented May 20, 2019

Or even better if you could share the original notebook?

@jianboy
Copy link
Author

jianboy commented May 20, 2019

Or even better if you could share the original notebook?

yes of course. the file is here:

http://cdn.yoqi.me/direct/2019-05-21/1_hello_tensorflow.ipynb

THe video of my operation:

http://cdn.yoqi.me/direct/2019-05-21/Video_2019-05-21_071457_edit.wmv

I can give you any information you need.

@rchiodo
Copy link
Contributor

rchiodo commented May 20, 2019

The import os change working directory stuff we put at the top of the file is messing up the

from __future__ import print_function

You can just delete the code that looks like this:

#%% Change working directory from the workspace root to the ipynb file location. Turn this addition off with the DataScience.changeDirOnImportExport setting
import os
try:
	os.chdir(os.path.join(os.getcwd(), '..\Import'))
	print(os.getcwd())
except:
	pass

That code is added to every import if you have this checked:
image

Otherwise I'm having trouble getting tensorflow to run. I keep getting this:

image

@rchiodo
Copy link
Contributor

rchiodo commented May 20, 2019

Yeah it looks like tensorflow doesn't have session anymore. I must have installed too new of a tensorflow

tensorflow/tensorflow#26816

@rchiodo
Copy link
Contributor

rchiodo commented May 20, 2019

Oh but you don't click on the tensorflow cell. So maybe my advice didn't matter. You're clicking on this cell in your gif:

image

And that is failing, possibly because you're using Python 2?

However in the video you posted, you mentioned the entire file wasn't there? Were you hoping it would open up the file as a jupyter notebook inside of VS Code?

Unfortunately the product doesn't work that way at the moment. Currently we expect you to work with '.py' files. The import notebook command merely extracts your python code.

We do have another open issue on inline notebooks though.
https://github.com/microsoft/vscode-python/issues/4575

@rchiodo
Copy link
Contributor

rchiodo commented May 20, 2019

Something like this:
https://atom.io/packages/hydrogen

@jianboy
Copy link
Author

jianboy commented May 20, 2019

Yeah it looks like tensorflow doesn't have session anymore. I must have installed too new of a tensorflow

tensorflow/tensorflow#26816

The function I want is just to preview the file when I open a jupyter file. and can run code.

@rchiodo
Copy link
Contributor

rchiodo commented May 20, 2019

I don't believe we have what you want (yet). Importing a notebook just turns it into the python code in your notebook. You then have to run each cell to view the output in the other pane.

@rchiodo
Copy link
Contributor

rchiodo commented May 20, 2019

If the hydrogen thing meets your needs, feel free to up vote the issue we have that I linked:
microsoft/vscode-python#4575

@rchiodo
Copy link
Contributor

rchiodo commented May 20, 2019

In the video you mention the 'right cannot display the html'. Can you elaborate on that comment? What HTML did you want? (Just wondering what we should do when we implement the hydrogen support)

@jianboy
Copy link
Author

jianboy commented May 20, 2019

In the video you mention the 'right cannot display the html'. Can you elaborate on that comment? What HTML did you want? (Just wondering what we should do when we implement the hydrogen support)

thank you, I want preview the whole jupyter file. I hope that we can get this feature out quickly.

@jianboy
Copy link
Author

jianboy commented May 20, 2019

when can I preview a jupyter file code ? I read Introduction of our plugin. it show have the function.

image

@rchiodo
Copy link
Contributor

rchiodo commented May 20, 2019

It does this now. All you have to do is click on the 'Run Below' command at the very top. That will run all 'cells' in the imported notebook. That's what the docs are showing anyway.

You probably want to uncheck this setting before you do the import though.
image

@jianboy
Copy link
Author

jianboy commented May 21, 2019

the hydrogen thing meets mine needs! but it can only use in the IDE of atom.

I have set it up according to your suggestion.
image

@jianboy
Copy link
Author

jianboy commented May 21, 2019

I often need to look at the contents of the jupyter file and then consider whether execute it.

@rchiodo
Copy link
Contributor

rchiodo commented May 21, 2019

Oh you want to see the current output. The last run you mean?

@rchiodo
Copy link
Contributor

rchiodo commented May 21, 2019

Our current implementation requires a rerun on every open. It's more like a terminal than a notebook viewer.

@jianboy
Copy link
Author

jianboy commented May 21, 2019

Oh you want to see the current output. The last run you mean?

yes, you are right.

@rchiodo
Copy link
Contributor

rchiodo commented May 21, 2019

Hmm, that might be possible sooner (before we do the hydrogen thing). On import, just fill the interactive window with the current output.

@jianboy
Copy link
Author

jianboy commented May 21, 2019

the plugin can privew the jupyter file. but can not run code.
https://marketplace.visualstudio.com/items?itemName=jithurjacob.nbpreviewer

@rchiodo rchiodo changed the title Importing a jupyter notebook is not generating correct code Importing a jupyter notebook should show the last output May 21, 2019
@rchiodo
Copy link
Contributor

rchiodo commented May 21, 2019

Thanks. That's super helpful.

@jianboy
Copy link
Author

jianboy commented May 21, 2019

I think if vscode can preview jupyter file ,and can run it. it may be better than the web page of jupyter notebook.

@rchiodo rchiodo self-assigned this May 28, 2019
@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

2 participants