jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.63k stars 4.89k forks source link

Workflow for moving notebook code to importable modules #1052

Open alexbw opened 8 years ago

alexbw commented 8 years ago

Opening an issue from a google groups thread.

Long-time notebook user. After many years of using notebooks to do data analysis in my PhD, and now handing the project over to others to continue the work, it's been pointed out quite rightly and clearly to me that much of what I've written is redundantly spread across many notebooks, and that some code which should be in importable modules is instead in a "copy and paste and reuse" state.

Is there any ongoing work on making this "modularization" process easier? Especially when working remotely, this is a pretty high-friction process -- find where in the file system the notebook is, ssh in, open up a new module file in a remote editor, selectively copy/paste code, try to import, fix import errors, try to import, succeed, try to use functions, fix errors, etc.

For instance, having %edit open up a text web-based editor would greatly speed up this process. One cell has %edit mymodule.py, the cell below is used for testing and debugging the contents of mymodule.py. I understand this would be very difficult to implement well, but I just wanted to check if there's anything like this on the horizon.

Although it is ultimately my responsibility to write reusable and maintainable code, the lure of notebooks for prototyping into creating a copy/paste mentality has been a source of frustration, and a pain point for the continued use of notebooks in our laboratory.

takluyver commented 8 years ago

I asked Alex to open this, because I think most of the pieces are in place that %edit could open the web based text editor for a module. We just need something to translate the paths in the edit payload into a URL from the starting directory of the notebook server.

minrk commented 8 years ago

I think the only thing that would be difficult is the wait that's the default behavior in the terminal, but I think it should be doable, as long as the file is within the notebook server's path (the kernel doesn't know this).

takluyver commented 8 years ago

The Qt console already has edit without wait-to-execute, so that shouldn't be an obstacle.

yuvipanda commented 5 years ago

https://github.com/ipython/ipynb is some movement along these lines.