I'd like to use Google Colab as a front-end to repeatedly run code that I am developing in a .py file on my Google Drive. Specifically, I want to edit that file with e.g. vim, and have the Colab Notebook repeatedly reload my changes.
Synchronizing the file with my Drive is easy enough, as is mounting that drive and importing the module once. However, reloading the module is not.
Using either %autoreload 2
or module = importlib.reload(module))
,
the notebook seems to eventually react to the changed file, but very slowly and unpredictably so. Remounting the Drive appears to have no effect. Doing a "factory reset" of the notebook does seem to work, but this is unacceptably slow because I must then input a new authorization code each time to a dialogue box.
Is there any way to achieve the desired behaviour?
I was able to do this with importlib
import some_module
import importlib
importlib.reload(some_module)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With