Synchronize .ipynb and .py to use ipython notebook and eclipse at the same time

1.2k Views Asked by At

I started programming some scripts with ipython notebook but now the project is becoming to big for a notebook. Nevertheless I love to execute my stuff in an ipython notebook (load de data only once, online figures...).

What I would want is to program everything with eclipse but executing it in ipython. I know I can save the notebooks as .py by adding the --script option at the beginning. But now I want to automatically make the process the other way around. I mean, I want my ipython notebook to reload de code I modify with Eclipse.

Is it possible? Should I make a program that makes it using the converter?

Thanks!!

1

There are 1 best solutions below

0
On

I found the solution for manually updating the functions without rerunning the whole .ipynb file. However, I do not know how to make it automated. Here is the solution:

Synchronizing code between jupyter/iPython notebook script and class methods

To cut it short you need to put reload function from importlib module in the cell of interest:

import babs_visualizations
from importlib import reload
reload(babs_visualizations)

Just a little addition: make sure that you are addressing the function in the form of moldule.function. If you previously imported function by from module import function and then reloaded the module the function will not be reloaded. You can put the function inside the notebook cell and rerun it to see, how the changes in the module affected the function output in the notebook. I hope this was helpful for someone.