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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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.
--
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