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

sphinx-autobuild becomes slow #82

Closed
moorepants opened this issue Jun 12, 2022 · 10 comments
Closed

sphinx-autobuild becomes slow #82

moorepants opened this issue Jun 12, 2022 · 10 comments
Labels
external Requires fixing something in an external library. jupyter-sphinx

Comments

@moorepants
Copy link
Owner

In general, the sphinx caching mechanism works well with sphinx-autobuild but if an error occurs in a jupyter-execute cell on a build, then the cache seems to be invalidated causing all of the pages to be rebuilt. This makes the edit review cycle too slow once many rst files that each take a long time to compute are present.

@moorepants moorepants added external Requires fixing something in an external library. jupyter-sphinx labels Jul 17, 2022
@moorepants
Copy link
Owner Author

I tried to speed up local builds using the only directive but it didn't seem to prevent the execution of the code in the only directive when not a draft. Here is the revert:

66ed399

@moorepants
Copy link
Owner Author

The matplotlib to_jshtml() calls take a lot of time.

@Peter230655
Copy link

You mean for animations?
I need this on my iPad, or is it Jupyter Notes? for animations, and it is terribly slow!!

@moorepants
Copy link
Owner Author

This issue has to do with sphinx and jupyter-sphinx, which you are presumably not using.

@moorepants
Copy link
Owner Author

I opened this issue on jupyter-sphinx: jupyter/jupyter-sphinx#219

@moorepants
Copy link
Owner Author

The matplotlib to_jshtml() calls take a lot of time.

One way to probably reduce the time of these calls is to down sample the simulation data to the frames per second desired, then pass to the animation. The animation probably generates an image for every time stamp and then down samples before displaying to get the right frames per second.

@Peter230655
Copy link

No, I definitely do not use this! :-)

@moorepants
Copy link
Owner Author

I tried setting the frame format on the writer directly to see if it would produce an svg (and maybe be faster) for animations but it seems to still generate pngs. I think the only way to speed up the animation generation from matplotlib is to reduce frames per second or reduce duration. For the 10 second nonholonomic animation, going to 10 fps makes it choppy, but 20 is fine. Here was the writer code:

#HTML(ani.to_jshtml(fps=fps))
from pathlib import Path
from matplotlib.animation import HTMLWriter

path = Path("temp.html")
writer = HTMLWriter(fps=fps,
                    embed_frames=True)
writer.frame_format = 'png'
ani.save(str(path), writer=writer)
HTML(path.read_text())

@moorepants
Copy link
Owner Author

I've added a new way to just run builds for a single chapter using an environment variable here: b9f119d This makes building much faster and solves the issue for me iterating locally on the books.

@moorepants
Copy link
Owner Author

I've opened the issue on jupyter-sphinx and have a local workaround, so closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Requires fixing something in an external library. jupyter-sphinx
Projects
None yet
Development

No branches or pull requests

2 participants