Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

user27182
Copy link
Contributor

@user27182 user27182 commented Sep 14, 2025

Resolve #220

  • Add tests for maximum vtksz file size
  • Convert vtksz files to screenshots and include them as part of generated test images
  • Add new --include_vtksz flag to enable these tests
  • Make work with pytest-xdist
  • Update docs

@github-actions github-actions bot added maintenance enhancement New feature or request labels Sep 14, 2025
@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2025

Codecov Report

❌ Patch coverage is 92.27642% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.56%. Comparing base (a15cc1a) to head (d95c0f5).

Files with missing lines Patch % Lines
pytest_pyvista/doc_mode.py 91.57% 12 Missing and 3 partials ⚠️
pytest_pyvista/pytest_pyvista.py 93.84% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #227      +/-   ##
==========================================
- Coverage   98.02%   96.56%   -1.47%     
==========================================
  Files           4        4              
  Lines         659      844     +185     
  Branches       82      104      +22     
==========================================
+ Hits          646      815     +169     
- Misses          7       20      +13     
- Partials        6        9       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@user27182
Copy link
Contributor Author

This was tested upstream with pyvista/pyvista#7878
It works, but it took approx 40 mins (without using parallel testing) to convert the 1540 vtksz files to screenshots using playwright:
https://github.com/pyvista/pyvista/actions/runs/17771842735/job/50509762607?pr=7878#step:13:51836

Wondering if maybe @akaszynski can comment on this? I think it's useful to test the interactive images (there are many open issues about interactive plots not working), but perhaps it's not worth it if it adds so much overhead?

Instead of generating vtksz screenshots here with pytest-pyvista, we could alternatively enable this as an option as part of the pyvista-plot directive directly. That way, the images would already be in the build directory. It would still require similar processing times to convert vtksz files to screenshots, though we can perhaps we can use Plotter.export_html directly instead of converting the vtksz files to html.

@akaszynski
Copy link
Member

This was tested upstream with pyvista/pyvista#7878
It works, but it took approx 40 mins (without using parallel testing) to convert the 1540 vtksz files to screenshots using playwright:

Considering we've had a few bad interactive images, I see no issue with including this in our testing. Ideally we could get the time down to ~20 minutes using parallel testing. pyvista-plot directive should just render static images using RenderWindow, and I'm prefer to keep separation of concerns.

We have enough servers to support this testing, and I have two spares should this end up bogging down our CI.

@user27182
Copy link
Contributor Author

This was tested upstream with pyvista/pyvista#7878
It works, but it took approx 40 mins (without using parallel testing) to convert the 1540 vtksz files to screenshots using playwright:

Considering we've had a few bad interactive images, I see no issue with including this in our testing. Ideally we could get the time down to ~20 minutes using parallel testing. pyvista-plot directive should just render static images using RenderWindow, and I'm prefer to keep separation of concerns.

We have enough servers to support this testing, and I have two spares should this end up bogging down our CI.

Thanks for the feedback. Let's keep this feature as part of pytest-pyvista then. I'll see if I can reduce the test times. If you happen to be familiar with taking screenshots of html files and can think of some other way to speed this up let me know...

@user27182
Copy link
Contributor Author

This was tested upstream with pyvista/pyvista#7878
It works, but it took approx 40 mins (without using parallel testing) to convert the 1540 vtksz files to screenshots using playwright:

Considering we've had a few bad interactive images, I see no issue with including this in our testing. Ideally we could get the time down to ~20 minutes using parallel testing.

We have enough servers to support this testing, and I have two spares should this end up bogging down our CI.

Reduced to 17 mins by using a single browser context with 584da66, see the run here:

https://github.com/pyvista/pyvista/actions/runs/17775690805/job/50522678419?pr=7878#step:13:51840

And I tried using -n8 for the tests to reduce this further and got worker errors, will need to make these tests thread-safe.

@akaszynski
Copy link
Member

Reduced to 17 mins by using a single browser context with 584da66, see the run here:

17 minutes is more than good! Nice work.

Copy link
Contributor Author

@user27182 user27182 left a comment

Choose a reason for hiding this comment

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

Can remove these skips once #230 is merged

@user27182 user27182 marked this pull request as ready for review September 18, 2025 23:09
@user27182
Copy link
Contributor Author

Ready for review

return output_paths


def _html_screenshots(html_files: list[Path], output_dir: Path, *, log: bool = True) -> list[Path]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Logging is currently enabled by default and cannot be configured. For the PyVista repo, this will print more than 3000 lines for the 1500+ images.

This should be configurable, but I would prefer to do this in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

This should be configurable, but I would prefer to do this in a separate PR.

Agreed. Let's disable this.

Comment on lines +292 to +297
batches = _split_batches(html_files, num_workers)
with multiprocessing.Pool(processes=num_workers) as pool:
results_nested = pool.starmap(
_process_html_screenshots,
[(batch, output_dir, log) for batch in batches],
)
Copy link
Member

Choose a reason for hiding this comment

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

Nice work here!

Copy link
Member

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

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

Impressed you got this working (and with multiprocessing no less). Nice work, LGTM.

@user27182 user27182 merged commit 635a98a into main Sep 20, 2025
14 of 15 checks passed
@user27182 user27182 deleted the feat/interactive branch September 20, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move vtksz file size tests to pytest-pyvista
4 participants