Have autoreload update shell namespace with reloaded module variables

This commit is contained in:
Grant Sanderson 2024-12-13 13:03:16 -06:00
parent 0c69ab6a32
commit 89e7a0a320

View file

@ -143,8 +143,11 @@ class InteractiveSceneEmbed:
def auto_reload(self):
"""Enables IPython autoreload for automatic reloading of modules."""
self.shell.magic("load_ext autoreload")
self.shell.magic("autoreload all")
def pre_cell_func(*args, **kwargs):
new_mod = ModuleLoader.get_module(self.shell.user_module.__file__, is_during_reload=True)
self.shell.user_ns.update(vars(new_mod))
self.shell.events.register("pre_run_cell", pre_cell_func)
def checkpoint_paste(
self,