Skip to content

Fix importing CVAT image XML files with annotation_type="cvat" - #728

Merged
guysmoilov merged 2 commits into
mainfrom
fix/cvat-xml-import
Oct 14, 2026
Merged

guysmoilov merged 2 commits into
mainfrom
fix/cvat-xml-import

Conversation

@guysmoilov

@guysmoilov guysmoilov commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

ds.import_annotations_from_files(annotation_type="cvat", path="annotations.xml", ...) failed with zipfile.BadZipFile. The "cvat" branch of AnnotationImporter passed every path that isn't a directory to load_cvat_from_zip. The "cvat_video" branch already sends .zip files to load_cvat_from_zip and other files to load_cvat_from_xml_file, and it already handles both image and video results. Both types now share that branch.

Related

CVAT brush masks (<mask>) still import as empty until the converter adds mask support (DagsHub/dagshub-annotation-converter#29). After that is released, users get mask support by upgrading dagshub-annotation-converter.

Testing

  • New tests/data_engine/annotation_import/test_cvat.py imports a CVAT image export as a .xml file and as a .zip. The .xml case fails without this fix.
  • tests/data_engine/annotation_import: 76 passed.

The "cvat" import path sent every non-directory path to load_cvat_from_zip,
so a plain annotations.xml failed with BadZipFile. "cvat_video" already
routed .zip and .xml files correctly, so both types now share that branch.
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 5a721337-d2d3-4431-9f00-9fb599e5813e
📥 Commits

Reviewing files that changed from the base of the PR and between 15d7bdd and da91967.

📒 Files selected for processing: 3
  • dagshub/data_engine/annotation/importer.py
  • tests/data_engine/annotation_import/test_cvat.py
  • tests/data_engine/annotation_import/test_cvat_video.py
🚧 Files skipped from review as they are similar to previous changes: 1
  • dagshub/data_engine/annotation/importer.py

Included review availability: This review used your included allowance. 3 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

📜 Recent review details
⏰ Context from checks skipped due to timeout: 6
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.13)
  • GitHub Check: Build documentation
📝 Walkthrough

The importer now shares CVAT and CVAT-video handling for directory, ZIP, and XML inputs. It tracks video annotations detected in CVAT imports. Tests cover image imports from XML and ZIP inputs and video detection for both import types.

Changes: CVAT import

Layer / File(s) Summary
Shared CVAT loader path
dagshub/data_engine/annotation/importer.py, tests/data_engine/annotation_import/test_cvat.py, tests/data_engine/annotation_import/test_cvat_video.py
The importer routes CVAT and CVAT-video through shared loaders, passes optional image dimensions, and tracks detected video annotations. Tests cover image annotations from XML and ZIP inputs and video detection for both import types.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to da919

The shared import path handles CVAT image inputs and routes detected video annotations to video conversion. No merge-blocking risk was identified in the reviewed changes.

Pre-merge checks: Passed 4
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the CVAT XML import failure, the routing fix, related behavior, and test coverage. It is directly related to the changeset.
Title check Passed The title clearly and concisely identifies the primary change: fixing CVAT image XML imports when using annotation_type="cvat".
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the CVAT trail
XML and ZIP now tell the tale
Images hop to img.jpg
Video flags appear when fit
Shared loaders keep paths neat
Tests thump out a steady beat

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: df6ca061-0b08-4869-bbff-5ea10a018754
📥 Commits

Reviewing files that changed from the base of the PR and between 996e58b and 15d7bdd.

📒 Files selected for processing (2)
  • dagshub/data_engine/annotation/importer.py
  • tests/data_engine/annotation_import/test_cvat.py

Included review availability: This review used your included allowance. 3 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

📜 Review details
⏰ Context from checks skipped due to timeout. (7)
  • GitHub Check: build (3.10)
  • GitHub Check: Build documentation
  • GitHub Check: build (3.13)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.11)
  • GitHub Check: Run linters

Comment thread dagshub/data_engine/annotation/importer.py
is_video_format only looked at the annotation type, so a "cvat" import of
a CVAT video export went to the image task conversion. The importer now
remembers when the CVAT loader returns video data.
@guysmoilov
guysmoilov merged commit 51caa88 into main Oct 14, 2026
12 checks passed
@guysmoilov
guysmoilov deleted the fix/cvat-xml-import branch October 14, 2026 18:56
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.

1 participant