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

Makes txt testing faster #178

Merged
merged 18 commits into from
Mar 19, 2020
Merged

Makes txt testing faster #178

merged 18 commits into from
Mar 19, 2020

Conversation

vinferrer
Copy link
Collaborator

@vinferrer vinferrer commented Mar 18, 2020

Closes #172
Shortens the txt.py testing

Proposed Changes

  • Now the tested acq file has only the trigger and other channel and the length of the channels is 1048560
  • All the downloads are done at the beggining and then the functions get the needed parameters. The only exception is test_populate_phys_input because the tested function has to read and this was giving problems if the file wasn't download inside the function
  • Testing reduced from 7 to 5 min

@vinferrer vinferrer added the Testing This is for testing features, writing tests or producing testing code label Mar 18, 2020
@vinferrer vinferrer self-assigned this Mar 18, 2020
@codecov
Copy link

codecov bot commented Mar 18, 2020

Codecov Report

Merging #178 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #178   +/-   ##
=======================================
  Coverage   94.15%   94.15%           
=======================================
  Files           7        7           
  Lines         565      565           
=======================================
  Hits          532      532           
  Misses         33       33           

Copy link
Collaborator

@eurunuela eurunuela left a comment

Choose a reason for hiding this comment

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

LGTM! 2 minutes faster is quite a thing! Do you know which of the tests is taking the longest to run?

I think that #162 could help with reducing testing time even more. What do you think @vinferrer ?

@rmarkello
Copy link
Member

Hey @vinferrer! Thanks so much for getting this started—I'm really glad to hear that the testing time is down ~25%!

My primary concern about this new implementation is that it might lead to difficulties detecting bugs in the codebase. That is, if there's an issue in any of the code that you've moved outside functions (e.g., if a file is accidentally moved or deleted from OSF, or there's an issue in the txt.read_header_and_channels() function for one of the test files), pytest will error during test collection rather than during the tests themselves. This makes debugging significantly harder—we don't get the helpful information pytest tries to give us about what tests failed / passed. (It will tell us what file / line caused the error during collection, but the whole testing suite aborts before any tests are run. You can see what this is like by modifying one of the OSF URLs in the download section of test_txt.py right now (e.g., change 'https://osf.io/4yudk/download' to 'https://osf.io/INVALID/download') and then running pytest on everything.)

One potential solution (as I described in #172) would be to use pytest.fixtures and add discrete download functions. When you do that, pytest is pretty verbose about exactly where the error is, and the entire test suite will run (even if some of the tests /fixtures fail). I'm happy to discuss alternatives or implementation specifics in more detail, but I think the current set-up (with much of the code living "freeform" inside the testing modules) isn't ideal.

@rmarkello
Copy link
Member

Since I haven't done much codestuff for phys2bids in a while would you be willing for me to maybe make a PR on your PR, implementing some of my suggestions? Let me know if you'd be open to that 😄

@vinferrer
Copy link
Collaborator Author

I see, let me code a bit tomorrow, I want a try do it by my self

@vinferrer
Copy link
Collaborator Author

LGTM! 2 minutes faster is quite a thing! Do you know which of the tests is taking the longest to run?

I think that #162 could help with reducing testing time even more. What do you think @vinferrer ?

That we can treat in another PR, but sure reducing check_multifreq time would be great

@vinferrer
Copy link
Collaborator Author

Hey @vinferrer! Thanks so much for getting this started—I'm really glad to hear that the testing time is down ~25%!

My primary concern about this new implementation is that it might lead to difficulties detecting bugs in the codebase. That is, if there's an issue in any of the code that you've moved outside functions (e.g., if a file is accidentally moved or deleted from OSF, or there's an issue in the txt.read_header_and_channels() function for one of the test files), pytest will error during test collection rather than during the tests themselves. This makes debugging significantly harder—we don't get the helpful information pytest tries to give us about what tests failed / passed. (It will tell us what file / line caused the error during collection, but the whole testing suite aborts before any tests are run. You can see what this is like by modifying one of the OSF URLs in the download section of test_txt.py right now (e.g., change 'https://osf.io/4yudk/download' to 'https://osf.io/INVALID/download') and then running pytest on everything.)

One potential solution (as I described in #172) would be to use pytest.fixtures and add discrete download functions. When you do that, pytest is pretty verbose about exactly where the error is, and the entire test suite will run (even if some of the tests /fixtures fail). I'm happy to discuss alternatives or implementation specifics in more detail, but I think the current set-up (with much of the code living "freeform" inside the testing modules) isn't ideal.

Talking about this, should we use the pytest.fixtures functions for dowloading or can we add also the common preproccessing before the asserts?

@vinferrer
Copy link
Collaborator Author

Okay guys I refactored the code and now I am using @pytest.fixture the testing time is more or less the same (5 min) except if codecov gets executed, then is 7. I think you can do the review now @rmarkello.

Copy link
Member

@rmarkello rmarkello left a comment

Choose a reason for hiding this comment

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

Thanks so much for making these edits, @vinferrer ! 💪

I have a few more thoughts / suggestions for the test suite overall, but I don't want to hold this PR up so I think we should merge this in !

@smoia
Copy link
Member

smoia commented Mar 19, 2020

@rmarkello, there is no rush in merging this in, if you want to make some suggestions!
However, if it's about testing in general, I would ask you to open another issue/PR/both (and merge this in, please!).

@rmarkello rmarkello merged commit 31e10bb into physiopy:master Mar 19, 2020
@vinferrer vinferrer deleted the txt_test branch March 20, 2020 08:27
@smoia smoia mentioned this pull request Mar 27, 2020
2 tasks
@vinferrer vinferrer changed the title Txt_test_faster Makes txt testing faster Mar 31, 2020
@smoia smoia added the released This issue/pull request has been released. label Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released This issue/pull request has been released. Testing This is for testing features, writing tests or producing testing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make txt test faster
4 participants