Giter Club home page Giter Club logo

Comments (10)

JackCaster avatar JackCaster commented on May 18, 2024 1

Instead of exporting the output in the Python interactive window (which may contain out of order execution and old outputs), we should be able to generate a .ipynb from the Python source directly. Moreover, it would be nice to have the possibility to automatically generate a *.ipynb (with the same file name) every time we are working with a Python source file that contains cells. In this way the script would be nicely rendered online or on Github.

from vscode-jupyter.

ronglums avatar ronglums commented on May 18, 2024 1

Great! Thank you both, I think I have a better understanding now. Let's start with a command to export the py files to .ipynb with an option to "Run all cells and include output in the notebook". The auto-generation on-the-fly work is more complicated - like @syagev said, we need to do it right and not overwrite those long-running cell results for sure! I opened #1469 to track it separately.

from vscode-jupyter.

rchiodo avatar rchiodo commented on May 18, 2024 1

Fixed the export to file in this PR here: microsoft/vscode-python#3548

from vscode-jupyter.

syagev avatar syagev commented on May 18, 2024

I second the suggestion by @JackCaster. I would even go one step further and have an option to do this conversion on-the-fly. So something like whenever I save a python file with jupyter markup a corresponding notebook is created. If it already exists, update only the cells that were modified since the last conversion and clear their output

from vscode-jupyter.

rchiodo avatar rchiodo commented on May 18, 2024

@ronglums, the minimum here is to provide a command. The requests from @JackCaster and @syagev add some other things that sound useful too. What do you think?

from vscode-jupyter.

ronglums avatar ronglums commented on May 18, 2024

We're working on adding a command for directly exporting from py files. @JackCaster @syagev, thanks for the suggestions. I'd like to get a better understanding of your use cases for "conversion on-the-fly". @JackCaster mentioned "In this way the script would be nicely rendered online or on Github." - Let me see if I get this right - if an ipynb is saved along with the py file, then you can view the ipynb files online or on GitHub in the notebook form instead of a py file. Is that what you meant? Curious how else would you use the on-the-fly conversion for?

from vscode-jupyter.

syagev avatar syagev commented on May 18, 2024

That's pretty much what I meant. Our use case is that we work directly only on the .py script, but we use notebooks for sharing results. So .py files are kept in version control while .ipynb files are usually excluded, and instead are manually uploaded to some notebook server for quick sharing. So it would be nice if the .ipynb is automagically updated every time .py is updated. But I think this has to be done smart or not done at all (like every automatic thing software does for us). For instance - think of a case where I have the output of a long running task in the .ipynb file and the extension overwrites that without me actually meaning for it to happen...

from vscode-jupyter.

rchiodo avatar rchiodo commented on May 18, 2024

Do you need the output in the generated ipynb file? Isn't it just generated by whomever views the file?

from vscode-jupyter.

syagev avatar syagev commented on May 18, 2024

What I usually would do is to run all cells and then share (so that results are immediately visible to the viewer). The idea of sharing the notebook as a way of sharing resukts is more for ppl to have interactive plots, inspection of variables, an easy way to reproduce, etc.

from vscode-jupyter.

JackCaster avatar JackCaster commented on May 18, 2024

@JackCaster mentioned "In this way the script would be nicely rendered online or on Github." - Let me see if I get this right - if an ipynb is saved along with the py file, then you can view the ipynb files online or on GitHub in the notebook form instead of a py file. Is that what you meant? Curious how else would you use the on-the-fly conversion for?

Exactly! Please have a look at this example. Note how the .ipynb file is rendered as a notebook directly on Github. The other advantage is that it becomes easier to share our work with people that prefer to work directly with Jupyter notebooks (and we get---finally---the ability to version control our notebooks).

To me, a simple command to export the script as a *.ipynb file would work just fine (for now :) ) as suggested by @rchiodo. I would also suggest to add an option like Run all cells and export to export the code together with the results, but also allow to export only the code (if this includes long running tasks)

from vscode-jupyter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.