8000 Deprecate MovieWriterRegistry cache-dirtyness system. by anntzer · Pull Request #13567 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Deprecate MovieWriterRegistry cache-dirtyness system. #13567

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

Merged
merged 1 commit into from
Jul 30, 2019

Conversation

anntzer
Copy link
Contributor
@anntzer anntzer commented Mar 2, 2019

MovieWriterRegistry has a fairly extensive system to cache whether movie
writer classes are available or not. Deprecate it and always perform
the check every time: for nearly all classes, the availability check is
either an import check (Pillow), or checking for whether an executable
is in the $PATH -- this is negligible compared to actually running the
executable to encode the movie.

The only exception is that ffmpeg actually checks whether it is
actually ffmpeg or ubuntu's broken libav. In order to avoid performing
that check (... which should still be not so slow) when Pillow is
available (Pillow is registered first, so comes first :)), add
MovieWriterRegistry.__iter__ which allows to get the first available
writer without checking the availability of the subsequent ones (this
behavior is consistent with MovieWriterRegistry.__getitem__ and
MovieWriterRegistry.list).

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

MovieWriterRegistry has a fairly extensive system to cache whether movie
writer classes are available or not.  Deprecate it and always perform
the check every time: for nearly all classes, the availability check is
either an import check (Pillow), or checking for whether an executable
is in the $PATH -- this is negligible compared to actually running the
executable to encode the movie.

The only exception is that ffmpeg actually checks whether it is
actually ffmpeg or ubuntu's broken libav.  In order to avoid performing
that check (... which should still be not so slow) when Pillow is
available (Pillow is registered first, so comes first :)), add
`MovieWriterRegistry.__iter__` which allows to get the first available
writer without checking the availability of the subsequent ones (this
behavior is consistent with `MovieWriterRegistry.__getitem__` and
`MovieWriterRegistry.list`).
Copy link
Member
@efiring efiring left a comment

Choose a reason for hiding this comment

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

This looks to me like a good simplification, but @dopplershift should have the final say.

if self.is_available(name):
yield name

def list(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really necessary? Isn't reg.list() just the same as list(reg)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see. This preserves API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I can deprecate it too if you don't mind the API change...

@dopplershift dopplershift merged commit 385dd94 into matplotlib:master Jul 30, 2019
@dopplershift dopplershift added this to the v3.2.0 milestone Jul 30, 2019
@anntzer anntzer deleted the moviewritercache branch July 30, 2019 08:23
@blusingh
Copy link
blusingh commented Jul 9, 2020

I was using 2.2.2 version and "import matplotlib.animation as animation" was stuck when executed in background. I updated to 3.2.2 which fixed that but now it get stuck at "Writer = animation.writers['ffmpeg']"

My testcase is quite simple:
import matplotlib.pyplot as plt
import matplotlib.animation as animation
Writer = animation.writers['ffmpeg']

When I run this file as python3 check.py & it is stuck forever, however when run in foreground it works well. Thanks

@dopplershift
Copy link
Contributor

@blusingh Can you open as a new issue rather than adding to this PR thread?

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

Successfully merging this pull request may close these issues.

4 participants
0