Syncronize Code Between Jupyter and External Scripts

28 views
Skip to first unread message

Utkonos

unread,
Jun 3, 2017, 2:19:08 PM6/3/17
to Project Jupyter
I have been running into the following problem with regards to developing in Jupyter and then deploying the code elsewhere. The code as deployed may have a bug or change that needs to occur, and then the code from the cell where it was located in the Jupyter notebook is now different and out of sync. I would like to know how to keep code in a cell synchronized with code outside in another file. I found the following question on StackOverflow that pertains to this problem exactly:

I will try this method of workflow, but I am curious whether there is a better mousetrap out there.

Here is my alternative, and I'd like to know the feasibility of it and whether it's a good idea or not:

There are multiple types of cell in Jupyter, and they behave differently. I am proposing a new type of cell called "Linked Snippet". A linked snippet cell would initially have a start and end line number and a file path. As long as the user the notebook is running as has write access the file path, the lines of code would be pulled into the cell. This code would be editable in jupyter, but would have the option of saving the contents of the cell and replacing the code between the two line numbers in the external file. This means no cells can overlap line numbers, and this would need to be enforced properly in Jupyter. Ideally, this would be bi-directional, and if the code in the external file changed, Jupyter would offer the user a chance to reload the cell before running. It also may need to change the line numbers that are syncronized at this point to make sure that the expected code is loaded into the cell.

Brian Granger

unread,
Jun 5, 2017, 1:57:29 PM6/5/17
to Project Jupyter
I think the best way to start playing with this is to build it as an
extension, and use notebook metadata that tracks separate file should
be pointed to by a given cell. I completely agree this is an good
usage case.
> --
> You received this message because you are subscribed to the Google Groups
> "Project Jupyter" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jupyter+u...@googlegroups.com.
> To post to this group, send email to jup...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jupyter/ae6819f5-f422-43aa-b7bf-0ba63bc523cd%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian E. Granger
Associate Professor of Physics and Data Science
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
bgra...@calpoly.edu and elli...@gmail.com
Reply all
Reply to author
Forward
0 new messages