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

Feature request: Autoreload for the same file #2275

Open
Splines opened this issue Dec 12, 2024 · 1 comment
Open

Feature request: Autoreload for the same file #2275

Splines opened this issue Dec 12, 2024 · 1 comment
Labels

Comments

@Splines
Copy link
Contributor

Splines commented Dec 12, 2024

In the last few weeks, 3b1b and me introduced these features to ease reloading:

The reload(x) command is essentially like quitting Manim altogether then starting it again with the -se option set to line x, but without the hassle of doing this manually and waiting for the complete window to be restarted. Instead, we reuse the window. Note that only your user-defined modules will be reloaded, no external libraries like numpy, no Python in-built modules like sys or time and also no manimlib files will be reloaded (the latter can be adjusted via a config option though).

The --autoreload command line flag will activate the autoreload IPython magic command. With this, your imported modules will be automatically reloaded for you such that you don't even have to execute reload() anymore.


The only missing piece (in my opinion), is a feature that enables auto-reloading also for classes/objects/etc. in the same file (and not only for imported files). E.g. consider this example

from manimlib import *


class ClassInSameFile:
    def answer(self):
        return "Hello from class in same file"


class AScene(Scene):
    def construct(self):
        ## Starting
        print("Hello from A")

        ## Class in same file
        test = ClassInSameFile()
        print(test.answer())

The autoreload feature from IPython will not pick up on changes to the string "Hello from class in same file" . If you do a reload(14) and then the checkpoint_paste(), it will work fine, but for the lazy programmer, that is one reload(14) too much 😅 A current workaround is to outsource ClassInSameFile to another file. Then import that into the original file and autoreload will do its magic.

Note that even if autoreload was perfect in the above sense, reload() might still have its raison d'être in the case where autoreloading might not work (due to whatever reason, I'm sure there might exist some...).

@Splines Splines added the bug label Dec 12, 2024
@Splines
Copy link
Contributor Author

Splines commented Dec 12, 2024

Tip

I've opened an issue for this on the IPython repository: ipython/ipython#14617

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant