jupytext icon indicating copy to clipboard operation
jupytext copied to clipboard

Behavior of "File -> Download as -> ..." depends on which formats the notebook is paired with

Open bzinberg opened this issue 4 years ago • 1 comments

Thank you for making Jupytext awesome.

Steps to repro:

  1. From the notebook web interface, create an empty Python notebook.
  2. Open the Python notebook, pair it to a light-script, save, and close.
  3. Open the .py file corresponding to the notebook.
  4. Unpair the .py file from the "ipynb document" format, and (I don't think this is necessary) delete the .ipynb file
  5. Create and evaluate a code cell, e.g. 1 + 1 (and see the output 2 in the browser)
  6. File -> Download as -> HTML, and open the HTML file. Result: no cell output.
  7. File -> Download as -> Notebook (ipynb), and open the notebook JSON. Result: no cell output.
  8. Now pair the notebook with ipynb document. No need to save, just enable the pairing.
  9. File -> Download as -> HTML, and open the HTML file. Result: yes cell output.
  10. File -> Download as -> Notebook (ipynb), and open the notebook JSON. Result: yes cell output.

I would expect "Download as" to produce something equivalent to what's shown in the browser, hence to include cell outputs if the download format has a way to include them (as HTML and ipynb do). And I wouldn't expect the behavior to depend on what output formats the notebook is paired with.

bzinberg avatar Mar 17 '20 16:03 bzinberg

Hello @bzinberg , thanks for asking.

Actually I'm not so sure of what happens exactly when you do Download as .... I've tried looking into this at https://github.com/jupyter/notebook, but I could not find out if what you get is the result of a nbconvert command applied to the local .ipynb file (or the .py file in your case?). To tell the truth I am even a bit surprised that you get anything meaningful when running these commands with the .py file opened!

Still, you're not the first one to ask. So if we could understand better what goes on when we click on Download as..., it would surely help. Also, in the past I note that we had an issue related to the document path (was .py in early versions, even when a .ipynb document was opened, cf. #118 ).

mwouts avatar Mar 18 '20 23:03 mwouts