-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Regression test for missing frames after exporting a CVAT dataset #8827
base: develop
Are you sure you want to change the base?
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes involve updates to three files: Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Debugger
participant Server
participant TestSuite
User->>Debugger: Start Debugging
Debugger->>Server: Launch REST API tests with `--verbose` and `--no-cov`
Server->>TestSuite: Run tests
TestSuite-->>Server: Return test results
Debugger-->>User: Display results
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
tests/python/rest_api/test_tasks.py (1)
1043-1043
: Use professional and descriptive label namesThe label name "goofy ahh car" may not be appropriate for a professional codebase. Consider using a more descriptive and formal label name to maintain code quality and readability.
Apply this diff to update the label name:
"labels": [{"name": "goofy ahh car"}] +"labels": [{"name": "car"}]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.vscode/launch.json
(1 hunks)tests/python/requirements.txt
(1 hunks)tests/python/rest_api/test_tasks.py
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- tests/python/requirements.txt
tests/python/rest_api/test_tasks.py
Outdated
def get_png_index(zinfo: zipfile.ZipInfo) -> int: | ||
name = PurePosixPath(zinfo.filename) | ||
if name.suffix.lower() != '.png': | ||
return -1 | ||
name = os.path.basename(name).removesuffix(name.suffix) | ||
idx = name[name.rfind('_') + 1:] | ||
assert idx.isnumeric() | ||
return int(idx) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve robustness of get_png_index
function to handle filenames without underscores
Currently, the get_png_index
function assumes that filenames have an underscore separating the base name and the index. If a filename does not contain an underscore, name.rfind('_')
returns -1
, and idx
becomes the entire name, which may not be numeric, causing an assertion error. To improve robustness, consider handling filenames without underscores and providing appropriate error handling.
Apply this diff to improve the function:
def get_png_index(zinfo: zipfile.ZipInfo) -> int:
name = PurePosixPath(zinfo.filename)
if name.suffix.lower() != '.png':
return -1
- name = os.path.basename(name).removesuffix(name.suffix)
- idx = name[name.rfind('_') + 1:]
- assert idx.isnumeric()
- return int(idx)
+ name_stem = name.stem
+ idx_parts = name_stem.split('_')
+ idx = idx_parts[-1] if len(idx_parts) > 1 else ''
+ if idx.isnumeric():
+ return int(idx)
+ else:
+ return -1
This change ensures that filenames without underscores or with non-numeric endings are handled gracefully.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def get_png_index(zinfo: zipfile.ZipInfo) -> int: | |
name = PurePosixPath(zinfo.filename) | |
if name.suffix.lower() != '.png': | |
return -1 | |
name = os.path.basename(name).removesuffix(name.suffix) | |
idx = name[name.rfind('_') + 1:] | |
assert idx.isnumeric() | |
return int(idx) | |
def get_png_index(zinfo: zipfile.ZipInfo) -> int: | |
name = PurePosixPath(zinfo.filename) | |
if name.suffix.lower() != '.png': | |
return -1 | |
name_stem = name.stem | |
idx_parts = name_stem.split('_') | |
idx = idx_parts[-1] if len(idx_parts) > 1 else '' | |
if idx.isnumeric(): | |
return int(idx) | |
else: | |
return -1 | |
@@ -444,6 +444,8 @@ | |||
"python": "${command:python.interpreterPath}", | |||
"module": "pytest", | |||
"args": [ | |||
"--verbose", | |||
"--no-cov", // vscode debugger might not work otherwise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove inline comment in JSON to maintain valid syntax
JSON does not support comments, so including an inline comment // vscode debugger might not work otherwise
in the args
array will cause a syntax error. Please remove the comment to ensure the launch.json
remains valid.
Apply this diff to remove the inline comment:
"args": [
"--verbose",
- "--no-cov", // vscode debugger might not work otherwise
+ "--no-cov",
"tests/python/rest_api/"
],
Consider documenting the reason for including --no-cov
in an external README or documentation file if necessary.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
"--no-cov", // vscode debugger might not work otherwise | |
"--no-cov", |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #8827 +/- ##
===========================================
- Coverage 73.93% 73.90% -0.03%
===========================================
Files 409 409
Lines 43930 43932 +2
Branches 3986 3986
===========================================
- Hits 32478 32468 -10
- Misses 11452 11464 +12
|
Co-authored-by: Maxim Zhiltsov <[email protected]>
Quality Gate passedIssues Measures |
This pull request provides test coverage for changes made in #8662 which helped resolve the issue GH-8483
Motivation and context
.vscode/launch.json
is patched with extrapytest
options for easier debuggingHow has this been tested?
The test checks that the exported dataset:
This testing mainly focuses on export in CVAT for video format but also confirms the correct behaviour when the format is different (COCO and Datumaro were checked)
Checklist
develop
branch(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.
Summary by CodeRabbit
New Features
Bug Fixes
Chores
pytest
andpytest-timeout
.Configuration Updates