Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have autoreload update shell namespace with reloaded module variables #2278

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading