I got a github repository having a program.py containing my python program and a notebook.ipynb.
In the notebook, i import program and call its functions. This works normally as i run the notebook locally.
On Colab, i can open the notebook easily but every time i push changes to my repo i have to delete and restart the Colab runtime, reclone repo to it in order to run the new code right. Is there any way to make this process less complicate?
CodePudding user response:
You can directly fetch the updated code for program.py
by using wget
to get the URL for the raw code, like this. That should eliminate the need for recloning.
And then to get the new versions produced by that code into your active namespace, without need for restarting the kernel, use reload
from importlib
to reload the functions in program.py
, see here and here and here for options. Plus, there is an autoreload magic for when you work in a Juptyer notebook. The pure Python I referenced first will work in the notebook, too. The pure Python versions are just less convenient.