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

Integration test for detect+track video #242

Merged
merged 28 commits into from
Dec 10, 2024

Conversation

sfmig
Copy link
Collaborator

@sfmig sfmig commented Nov 12, 2024

Description

What is this PR?

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
To ensure we maintain the functionality of the detector and tracker when refactoring related parts of the codebase.

What does this PR do?

  • Adds an integration test for the detect-and-track-video command, when ground-truth is passed.
    • Downloads sample data from GIN using pooch
    • Parametrises the test for different optional outputs (save frames or not, save tracked video or not).
  • Adds a caching step to the Github actions workflow in CI
  • Additionally, the CLI help for the --output-dir is edited, to clarify it refers to the root name of the output directory rather than the full path to it (I opened an issue Support specifying output directory path for detect-and-track-video #246 to support this other functionality)

Questions

I initially was parametrising possible flags for --output-dir too, but decided to remove them to reduce the run time of these tests and thinking this would be better covered in a unit test. But opinions are welcome on this!

References

For now, the integration test checks the command runs successfully and the expected outputs are created.

After reviewing and fixing the tracking evaluation, the tests should be expanded to confirm the output csv files contain the expected metrics (PR #243).

How has this PR been tested?

Existing and new tests pass locally and in CI.

Does this PR require an update to the documentation?

N/a

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality
  • [ n/a ] The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@sfmig sfmig mentioned this pull request Nov 12, 2024
7 tasks
@codecov-commenter
Copy link

codecov-commenter commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.18%. Comparing base (ba60fa9) to head (f65dfb2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #242      +/-   ##
==========================================
+ Coverage   47.98%   48.18%   +0.19%     
==========================================
  Files          24       24              
  Lines        1567     1567              
==========================================
+ Hits          752      755       +3     
+ Misses        815      812       -3     

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

@sfmig sfmig force-pushed the smg/detect-and-track-integration-test branch from e85a39e to 629bccf Compare November 14, 2024 15:23
@sfmig sfmig marked this pull request as ready for review November 14, 2024 16:53
@sfmig sfmig requested a review from niksirbi November 14, 2024 18:10

# Download the registry file from GIN
# Force to download it fresh every time by using a timestamped filename
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as @niksirbi made me realise, if knonw_hash = None, the file is always downloaded.

So there is no need to set it to a different name

conftest.py Show resolved Hide resolved
Copy link
Member

@niksirbi niksirbi left a comment

Choose a reason for hiding this comment

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

Very nice @sfmig! The integration test is very understandable and readable (even for me, having my first contact with this repo), and it makes sense.

The pooch bits we have already discussed intensely, and I think you can get rid of the time stamp.

FYI I timed the tests on my Macbook and they took:

  • ~11 min the first time they were run (so including pooch download time)
  • ~2.5 minutes for subsequent runs

Most time is spent on the new test_inference.py test.

This PR is good to go as is, but I'm wondering if you've considering running this on a smaller dataset (mostly in the interest of speeding up CI, if that's not so important ignore me).

tests/fixtures/integration.py Outdated Show resolved Hide resolved
tests/fixtures/integration.py Outdated Show resolved Hide resolved
tests/fixtures/integration.py Outdated Show resolved Hide resolved
@sfmig sfmig force-pushed the smg/detect-and-track-integration-test branch from bc5fe5e to ea6adc6 Compare December 9, 2024 22:32
@sfmig sfmig force-pushed the smg/detect-and-track-integration-test branch from 348a409 to 3ac53ca Compare December 10, 2024 12:47
@sfmig sfmig force-pushed the smg/detect-and-track-integration-test branch from 3ac53ca to d3ec68e Compare December 10, 2024 12:49
@sfmig
Copy link
Collaborator Author

sfmig commented Dec 10, 2024

thanks for the feedback @niksirbi !

The main bottleneck is not the size of the sample data, but the download of the trained model (which is ~160MB). I checked if it was possible to compress the data further to speed this up (increasing the level of compression with zip -r -9) but there was not much further compression gain. I think it is because the .ckpt file itself is already a compressed directory.

For now I have marked the integration test as slow, so that it can be skipped locally if desired with pytest -m "not slow". I also skip the slow tests in CI if the runner is macos-13 as it is very often the slowest of all runners by quite a bit (see others discussing this too).

One thing I didn't know that was very useful in this process is that pytest can return setup and call times using the --durations=0 flag

@sfmig sfmig merged commit 3532188 into main Dec 10, 2024
7 checks passed
@sfmig sfmig deleted the smg/detect-and-track-integration-test branch December 10, 2024 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants