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
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions manimlib/scene/scene_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ def reload_scene(self, embed_line: int | None = None) -> None:

def auto_reload(self):
"""Enables IPython autoreload for automatic reloading of modules."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to adjust the docstring to make clear we don't use the %autoreload IPython line magic and instead reload user modules with our custom logic

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,
Expand Down