Skip to content

Commit 39fbb67

Browse files
authored
Have autoreload update shell namespace with reloaded module variables (3b1b#2278)
* Have autoreload update shell namespace with reloaded module variables * Update comments
1 parent c13d2a9 commit 39fbb67

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

docs/source/getting_started/configuration.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ flag abbr function
6363
``--video_dir VIDEO_DIR`` Directory to write video
6464
``--config_file CONFIG_FILE`` Path to the custom configuration file
6565
``--log-level LOG_LEVEL`` Level of messages to Display, can be DEBUG / INFO / WARNING / ERROR / CRITICAL
66-
``--autoreload`` Automatically reload Python modules to pick up code changes across different files
66+
``--autoreload`` Automatically reload Python modules to pick up code changes across during an interactive embedding
6767
========================================================== ====== =====================================================================================================================================================================================================
6868

6969
custom_config

manimlib/scene/scene_embed.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,12 @@ def reload_scene(self, embed_line: int | None = None) -> None:
142142
self.shell.run_line_magic("exit_raise", "")
143143

144144
def auto_reload(self):
145-
"""Enables IPython autoreload for automatic reloading of modules."""
146-
self.shell.magic("load_ext autoreload")
147-
self.shell.magic("autoreload all")
145+
"""Enables reload the shell's module before all calls"""
146+
def pre_cell_func(*args, **kwargs):
147+
new_mod = ModuleLoader.get_module(self.shell.user_module.__file__, is_during_reload=True)
148+
self.shell.user_ns.update(vars(new_mod))
149+
150+
self.shell.events.register("pre_run_cell", pre_cell_func)
148151

149152
def checkpoint_paste(
150153
self,

0 commit comments

Comments
 (0)