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 #5675

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

Comments

Projects
None yet
5 participants
@jianboy
Copy link

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

@pvscbot pvscbot added the classify label May 18, 2019

@pvscbot pvscbot removed the classify label May 20, 2019

@rchiodo

This comment has been minimized.

Copy link

commented May 20, 2019

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

@rchiodo rchiodo added the info needed label May 20, 2019

@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

This comment has been minimized.

Copy link

commented May 20, 2019

Or even better if you could share the original notebook?

@jianboy

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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.
#4575

@rchiodo

This comment has been minimized.

Copy link

commented May 20, 2019

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

@jianboy

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented May 20, 2019

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

@rchiodo

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

commented May 21, 2019

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

@rchiodo

This comment has been minimized.

Copy link

commented May 21, 2019

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

@rchiodo

This comment has been minimized.

Copy link

commented May 21, 2019

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

@jianboy

This comment has been minimized.

Copy link
Author

commented May 21, 2019

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

yes, you are right.

@rchiodo

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link

commented May 21, 2019

Thanks. That's super helpful.

@jianboy

This comment has been minimized.

Copy link
Author

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 removed the info needed label May 21, 2019

@ronglums ronglums added the P2 label May 23, 2019

@rchiodo rchiodo self-assigned this May 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.