-
Notifications
You must be signed in to change notification settings - Fork 460
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
Update plots before scraping #5283
Changes from all commits
d5ba83e
f93ad14
1ebe8cb
444c87f
2de61ec
dfad6ed
2ee4c09
ceb9116
e876082
65208f7
84faff6
c2a6efe
63cb55c
e161c7a
a514b1a
9070a0e
9111266
f4a003d
c088baf
507bc0c
f6b6109
97679cf
b15ef1b
a829fee
659f3c1
e0a550e
5cb7ae4
7959a11
789d628
8110f17
7b74324
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,14 @@ def html_rst( | |
return images_rst | ||
|
||
|
||
def _process_events_before_scraping(plotter): | ||
"""Process events such as changing the camera or object before scraping.""" | ||
if plotter.iren is not None and plotter.iren.initialized: | ||
plotter.update() | ||
if hasattr(plotter, "app") and plotter.app is not None: | ||
plotter.app.processEvents() | ||
|
||
|
||
class Scraper: | ||
""" | ||
Save ``pyvista.Plotter`` objects. | ||
|
@@ -84,7 +92,8 @@ def __call__(self, block, block_vars, gallery_conf): | |
image_names = list() | ||
image_path_iterator = block_vars["image_path_iterator"] | ||
figures = pyvista.plotting.plotter._ALL_PLOTTERS | ||
for _, plotter in figures.items(): | ||
for plotter in figures.values(): | ||
_process_events_before_scraping(plotter) | ||
fname = next(image_path_iterator) | ||
if hasattr(plotter, "_gif_filename"): | ||
# move gif to fname | ||
|
@@ -97,7 +106,7 @@ def __call__(self, block, block_vars, gallery_conf): | |
return figure_rst(image_names, gallery_conf["src_dir"]) | ||
|
||
|
||
class DynamicScraper: | ||
class DynamicScraper: # pragma: no cover | ||
""" | ||
Save ``pyvista.Plotter`` objects dynamically. | ||
|
||
|
@@ -110,6 +119,10 @@ class DynamicScraper: | |
|
||
""" | ||
|
||
def __repr__(self): | ||
"""Return a stable representation of the class instance.""" | ||
return f"<{type(self).__name__} object>" | ||
|
||
Comment on lines
+122
to
+125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alexrockhill, why was this needed? We do not intend for this class to be used or displayed to users as far as I understand? Asking because I'm going to see if I can re-land this PR with less impact There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was added when I was trying to add coverage of the dynamic scraper but then not removed when adding that coverage exposed a bug where the dynamic scraper failed to close plots and so that was punted to a future PR. |
||
def __call__(self, block, block_vars, gallery_conf): | ||
"""Save the figures generated after running example code. | ||
|
||
|
@@ -122,7 +135,8 @@ def __call__(self, block, block_vars, gallery_conf): | |
image_names = list() | ||
image_path_iterator = block_vars["image_path_iterator"] | ||
figures = pyvista.plotting.plotter._ALL_PLOTTERS | ||
for _, plotter in figures.items(): | ||
for plotter in figures.values(): | ||
_process_events_before_scraping(plotter) | ||
fname = next(image_path_iterator) | ||
# if hasattr(plotter, '_gif_filename'): | ||
# raise RuntimeError('GIFs are not supported with DynamicScraper.') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,14 @@ meshio<5.4.0 | |
nest_asyncio<1.5.9 | ||
numpydoc==1.6.0 | ||
param<2.1.0 | ||
PyQt6!=6.6.1,<6.7.0 | ||
PyQt6-Qt6!=6.6.1,<6.7.0 | ||
pytest<7.5.0 | ||
pytest-cov<4.2.0 | ||
pytest-memprof<0.3.0 | ||
pytest-xdist<3.4.0 | ||
pytest_pyvista==0.1.8 | ||
qtpy<2.5.0 | ||
Comment on lines
+15
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do not test Qt dependencies in PyVista. This was a part of the entire motivation for making PyVistaQt a separate repository |
||
Sphinx<7.2.0 | ||
sphinx-gallery<0.15.0 | ||
sympy<1.13.0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woah... why was this added here? This needs to be removed ASAP as this section of the tests is strictly non-graphics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further I want to discourage the use of custom scripts from external projects in our core CI routines. We should keep any configuration and set up limited to well-established GitHub Actions or scripts managed by PyVista.
Adding and executing arbitrary shell scripts is a major red flag and security risk albeit this is from a well-trusted downstream project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds reasonable. They were added for PyQtx.QWidgets.QApplication.process_events testing. Not sure there is a way to fake that for non-graphics tests, I just don't know there might be though. Otherwise since it was tested it could be no covered.