Skip to content

Feature/auto detect format #77

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

rajatkriplani
Copy link

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?
This PR aims to improve user experience by automatically detecting the format based on the file's content.

What does this PR do?
This PR introduces automatic detection for the format of input annotation files:

  • Adds a private helper function _detect_format within load_bboxes.py
  • Modifies from_files function signature to make the format argument optional, defaulting "auto".
  • When format="auto", from_files now calls _detect_format on the first input file to determine the format for loading.
  • Adds new unit tests to cover the format="auto" success and failure scenarios.

References

Closes #43

How has this PR been tested?

The code has been tested locally by running pytest. New unit tests have been added to tests/test_unit/test_annotations/test_load_bboxes.py

Is this a breaking change?

No. This PR only adds a new, optional behavior (format="auto") as the default.

Does this PR require an update to the documentation?

Yes. The docstring for the ethology.annotations.io.load_bboxes.from_files function

Checklist:

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

Copy link

codecov bot commented Apr 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.99%. Comparing base (5dbd591) to head (793a6dc).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #77      +/-   ##
==========================================
+ Coverage   98.82%   98.99%   +0.17%     
==========================================
  Files           5        5              
  Lines         255      299      +44     
==========================================
+ Hits          252      296      +44     
  Misses          3        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.

@sfmig
Copy link
Contributor

sfmig commented Apr 3, 2025

Hi @rajatkriplani, thanks for this!

I approved the CI workflows now, would you mind having a look at the failed checks?

Additionally, we usually open PRs separately for different features / issues, but I noticed in this PR the diff with main includes the labelling guide as well as the auto detect format work. Would you mind changing it so that here you only show the auto detect format work? That makes it easier for the reviewer to go through.

Feel free to have a go, let me know if you get stuck at any point.

@rajatkriplani rajatkriplani force-pushed the feature/auto-detect-format branch from 47105b4 to aacdbe8 Compare April 3, 2025 14:17
@rajatkriplani
Copy link
Author

Hi @sfmig I have improved the test coverage, still the following line are uncovered in ethology/annotations/io/load_bboxes.py

except Exception as e:  # Catch other potential file reading errors
         raise ValueError(f"Could not read file {file_path}: {e}") from e

for the above mocking is required, so should I go with unittest.mock?

@sfmig
Copy link
Contributor

sfmig commented Apr 8, 2025

Hi @rajatkriplani,

Yes do have a go at using unittest.mock for this. You may find examples of its use in the movement tests codebase.

Hope this helps!

@sfmig
Copy link
Contributor

sfmig commented Apr 8, 2025

Also, do have a look at the docs building check which seems to be failing (alongside the code coverage checks)

@sfmig sfmig self-requested a review April 8, 2025 12:33
@rajatkriplani
Copy link
Author

@sfmig I have done the mocking for some tests please have a look at it.

@rajatkriplani
Copy link
Author

Hello @sfmig
I am assuming only the doc build is remaining. Please know how to make changes in the doc (and which doc?)?

@rajatkriplani
Copy link
Author

Hello @sfmig just dropping a quick follow-up here since Zulip’s been a bit quiet — would love any further thoughts or feedback on this when you get a chance.

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.

Automatically detect likely format of input annotation file
2 participants