Skip to content

Commit

Permalink
Have autoreload update shell namespace with reloaded module variables (
Browse files Browse the repository at this point in the history
…#2278)

* Have autoreload update shell namespace with reloaded module variables

* Update comments
  • Loading branch information
3b1b authored Dec 13, 2024
1 parent c13d2a9 commit 39fbb67
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/source/getting_started/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ flag abbr function
``--video_dir VIDEO_DIR`` Directory to write video
``--config_file CONFIG_FILE`` Path to the custom configuration file
``--log-level LOG_LEVEL`` Level of messages to Display, can be DEBUG / INFO / WARNING / ERROR / CRITICAL
``--autoreload`` Automatically reload Python modules to pick up code changes across different files
``--autoreload`` Automatically reload Python modules to pick up code changes across during an interactive embedding
========================================================== ====== =====================================================================================================================================================================================================

custom_config
Expand Down
9 changes: 6 additions & 3 deletions manimlib/scene/scene_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,12 @@ def reload_scene(self, embed_line: int | None = None) -> None:
self.shell.run_line_magic("exit_raise", "")

def auto_reload(self):
"""Enables IPython autoreload for automatic reloading of modules."""
self.shell.magic("load_ext autoreload")
self.shell.magic("autoreload all")
"""Enables reload the shell's module before all calls"""
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,
Expand Down

0 comments on commit 39fbb67

Please sign in to comment.