You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously we did all exporting to python from the interactive window or from a jupyter notebook document via a single global install of the nbconvert python package. This caused the following issues 1. NBConvert must be installed somewhere, 2. Requires running Python code 3. NBConvert is slow to work. So we did work this last sprint to allow for a much quicker plain export of notebooks (or interactive window) to python scripts just using typescript code.
We now have a setting jupyter.pythonExportMethod with three settings. direct moves over the exact code from notebook cells into the python file as is, and is the default setting. This does mean that ipython magic commands such as %whos (which are not valid python) are copied over as is. commentMagics setting does a very basic per line check to comment out one line magics and shell commands from the notebook code when converting to the python file. nbconvert setting uses nbconvert as the previous code did. Nb convert will do a full conversion of ipython syntax (!shell commands %magic commands) into valid python syntax.
If you have never done an export before you might get a prompt to install 'nbconvert' python module when using the 'nbconvert' mode. We didn't specifically address any issues with that mode, but we have had some reports of the install not working correctly here, so if you see issues please file them regarding that as well.
Testing for this is as follows:
Install the latest Jupyter Insiders Extension + Python Extension
Grab or create a few notebook documents (not providing any as the more variety that we have here the better). Documents should have both code and markdown cells.
Open the documents in Visual Studio Code
Using the "Jupyter: Export" commands or the Export button in the notebook UI try exporting the documents using all three of the settings above.
The export should create a new .py file for all three settings. In 'direct' mode magic commands like %whos should be ported directly. In 'commentMagics' lines leading with a jupyter magic or shell command should be commented out. In 'nbconvert' mode magics and shells should be converted to get_ipython() syntax.
Markdown cells should have a markdown cell marker in the .py file (# %% [markdown]) by default and should be commented out.
Run some sample code in the python interactive window. Perform the same steps from the interactive window for all three exports as above.
Example:
Expected file with 'direct' export:
Expected file with 'commentMagics' export:
Expected file with 'nbconvert' export:
@IanMatthewHuff Removing my assignment for now as I've gone through variations of the steps mentioned above. But since I can't seem to find a way to get the nbconvert setting to work, if you'd like me re-test with a different set up or with some troubleshooting, please just reassign me. Thank you!
@bamurtaugh No don't worry about it. Thanks for the testing. We added the new paths to export without requiring nbconvert, but the nbconvert still has a path that doesn't correctly prompt for the install. We're going to handle this with a follow up fix next release.
Refs: microsoft/vscode-jupyter#5222
Complexity: 3
Author: @IanMatthewHuff
Create Issue
File bugs on the Jupyter repo here: https://github.com/microsoft/vscode-jupyter/issues
Previously we did all exporting to python from the interactive window or from a jupyter notebook document via a single global install of the nbconvert python package. This caused the following issues 1. NBConvert must be installed somewhere, 2. Requires running Python code 3. NBConvert is slow to work. So we did work this last sprint to allow for a much quicker plain export of notebooks (or interactive window) to python scripts just using typescript code.
We now have a setting
jupyter.pythonExportMethod
with three settings.direct
moves over the exact code from notebook cells into the python file as is, and is the default setting. This does mean that ipython magic commands such as %whos (which are not valid python) are copied over as is.commentMagics
setting does a very basic per line check to comment out one line magics and shell commands from the notebook code when converting to the python file.nbconvert
setting uses nbconvert as the previous code did. Nb convert will do a full conversion of ipython syntax (!shell commands %magic commands) into valid python syntax.If you have never done an export before you might get a prompt to install 'nbconvert' python module when using the 'nbconvert' mode. We didn't specifically address any issues with that mode, but we have had some reports of the install not working correctly here, so if you see issues please file them regarding that as well.
Testing for this is as follows:
Example:
Expected file with 'direct' export:
Expected file with 'commentMagics' export:
Expected file with 'nbconvert' export:
Known issues:
The commentMagics setting is very basic, it will just comment out magics and shell commands that lead lines. It won't comment out things like cell or magic assignments: https://ipython.readthedocs.io/en/stable/interactive/python-ipython-diff.html such as
my_files = !ls
.Note: I'll be out the first day or two of endgame, but available for help starting Wed the 27th.
The text was updated successfully, but these errors were encountered: