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

Update plots before scraping #5283

Merged
merged 31 commits into from
Dec 8, 2023
Merged

Update plots before scraping #5283

merged 31 commits into from
Dec 8, 2023

Conversation

alexrockhill
Copy link
Contributor

Fixes #5277

@tkoyama010 tkoyama010 added the bug Uh-oh! Something isn't working as expected. label Dec 6, 2023
@alexrockhill
Copy link
Contributor Author

Can you check if the plotter is initialized before calling update? That would fix the errors:

FAILED tests/plotting/test_scraper.py::test_scraper[1] - RuntimeError: Render window interactor must be initialized before processing events.

Not sure how to do that if anyone has a second.

@alexrockhill
Copy link
Contributor Author

I ran this locally and it fixes my issue.

Copy link

codecov bot commented Dec 6, 2023

Codecov Report

Merging #5283 (7b74324) into main (5b0d2ab) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5283   +/-   ##
=======================================
  Coverage   96.20%   96.20%           
=======================================
  Files         134      134           
  Lines       22712    22700   -12     
=======================================
- Hits        21850    21839   -11     
+ Misses        862      861    -1     

@tkoyama010
Copy link
Member

tkoyama010 commented Dec 6, 2023

Thanks for your contribution. To pass test coverage, we need a sample for adding a test. Please provide us with a sample that you have run locally.

@alexrockhill
Copy link
Contributor Author

alexrockhill commented Dec 6, 2023

I ran the sample linked in the issue but that involves MNE and is far too large but the gist is to set the camera before rendering and make sure that has taken effect. I implemented a minimal version in tinypages. Should be good to go now.

@tkoyama010
Copy link
Member

pre-commit.ci autofix

@tkoyama010
Copy link
Member

pre-commit.ci autofix

@alexrockhill
Copy link
Contributor Author

Sorry about not figuring out the pre-commit protocol, got it working now and it's very nice.

I'm not sure if it's easiest to mark this to test it only on the CIs with the MNE dependencies. I'm not sure of a way to do that in this case though... pytest.mark I don't think would work. Maybe just some logic about trying and failing dependencies. I don't want it to be overly complicated and not look good though.

requirements_test.txt Outdated Show resolved Hide resolved
requirements_test.txt Outdated Show resolved Hide resolved
@tkoyama010
Copy link
Member

tkoyama010 commented Dec 6, 2023

Sorry about not figuring out the pre-commit protocol, got it working now and it's very nice.

Never mind. We are happy to show that our CI is excellent.

I'm not sure if it's easiest to mark this to test it only on the CIs with the MNE dependencies. I'm not sure of a way to do that in this case though... pytest.mark I don't think would work. Maybe just some logic about trying and failing dependencies. I don't want it to be overly complicated and not look good though.

I am not as familiar with this bug as you are, but this is a common problem in all environments in my mind. So I'm fine as is. I got it what you say. This is the bug when Plotter has app. But still fine as is.

Copy link
Member

@tkoyama010 tkoyama010 left a comment

Choose a reason for hiding this comment

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

Would you mind the output of the image to three pieces in order to keep the existing test intact?

tests/test_tinypages.py Outdated Show resolved Hide resolved
tests/tinypages/plot_cone.py Outdated Show resolved Hide resolved
tests/test_tinypages.py Outdated Show resolved Hide resolved
tkoyama010
tkoyama010 previously approved these changes Dec 6, 2023
Copy link
Member

@tkoyama010 tkoyama010 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@alexrockhill
Copy link
Contributor Author

I moved the tests to test_scraper and where they actually had cover which was good because it actually needed to check not just that there was an app but also that it wasn't None.

tests/plotting/test_scraper.py Outdated Show resolved Hide resolved
@alexrockhill
Copy link
Contributor Author

I got down a bit of a rabbit hole trying to add coverage for the dynamic scraper but it looks like it doesn't have any coverage in general so maybe not the PR to do it in. I was close to adding it, just with plotters[n].show(interactive=False) there were 7 vtk objects that we not garbage collected. Might be something to look into as I guess that may cause memory leaks if you use the dynamic scraper?

Should be good to go after implementing the change you asked for with a new test function without branching logic.

tests/plotting/test_scraper.py Outdated Show resolved Hide resolved
tests/plotting/test_scraper.py Outdated Show resolved Hide resolved
@alexrockhill
Copy link
Contributor Author

Looks good to go by me

Copy link
Member

@tkoyama010 tkoyama010 left a comment

Choose a reason for hiding this comment

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

LGTM. Let's make a test of DynamicScraper in the future.

@alexrockhill
Copy link
Contributor Author

Thanks for the help and review @tkoyama010

@tkoyama010 tkoyama010 merged commit f96feb4 into pyvista:main Dec 8, 2023
25 checks passed
@alexrockhill alexrockhill deleted the update branch December 8, 2023 21:37
Comment on lines +169 to +173
- name: Setup xvfb dependencies
run: |
git clone --depth=1 https://github.com/mne-tools/mne-python.git --branch main --single-branch
./mne-python/tools/setup_xvfb.sh

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Comment on lines +15 to +22
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
Copy link
Member

Choose a reason for hiding this comment

The 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

@banesullivan
Copy link
Member

Apologies @alexrockhill and @tkoyama010 but these changes need to be reverted as they are too impactful and need to undergo a more thorough review

banesullivan added a commit that referenced this pull request Dec 9, 2023
banesullivan added a commit that referenced this pull request Dec 9, 2023
Comment on lines +122 to +125
def __repr__(self):
"""Return a stable representation of the class instance."""
return f"<{type(self).__name__} object>"

Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Uh-oh! Something isn't working as expected.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Scraper doesn't let code execution finish before taking screenshot
3 participants