Repository navigation
fix(dataset): raise when an image cannot be written during export - #2772
Merged
Borda merged 4 commits intoOct 22, 2026
Merged
Conversation
Signed-off-by: tongwentao <twtzs@foxmail.com>
Signed-off-by: tongwentao <twtzs@foxmail.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Both narrowly scoped failure checks have focused regression coverage and matching documentation, with no unresolved findings.
No open issues 🎉
What changed in this PR
🟢 Approve — This change prevents silent image-write failures in Supervision’s in-memory dataset exports.
Changes:
- Raise
OSErrorwith the destination path when either exporter receives a failed write result. - Add filesystem-failure and successful pixel-preservation tests.
- Document the exception and update the changelog.
No actionable issues identified. Behavior, error handling, tests, and documentation are covered by the supplied review evidence; tests were not rerun here.
Quality: code 5/5 (minimal checks), tests 5/5 (failure and success coverage), documentation 5/5 (matching updates). Risk: 1/5.
| File | Description |
|---|---|
| tests/dataset/test_utils.py | Tests detection image-write failures and pixel preservation. |
| tests/dataset/test_core.py | Tests classification image-write failures and pixel preservation. |
| src/supervision/dataset/utils.py | Checks detection image writes and documents errors. |
| src/supervision/dataset/core.py | Checks classification image writes and documents errors. |
| docs/changelog.md | Announces the export failure handling. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2772 +/- ##
=======================================
Coverage 94% 94%
=======================================
Files 83 83
Lines 13659 13661 +2
=======================================
+ Hits 12863 12867 +4
+ Misses 796 794 -2 🚀 New features to boost your workflow:
|
Borda
approved these changes
Oct 22, 2026
Borda
added a commit
to moyunliuyin/supervision
that referenced
this pull request
Oct 22, 2026
Changes: - Merge fetched develop at b4225e5 into fix/pascal-voc-devkit-extents, retaining the Pascal VOC conversion change and its tests alongside the target dataset export, JSON sink, compact-mask, metrics, and test updates. - Resolve docs/changelog.md by retaining the PR Pascal VOC note and target notes for roboflow#2772, roboflow#2771, and roboflow#2767. Impact: - Brings the PR branch up to the fetched target implementation while preserving the PR behavior and release note. - Adds the target 32 other changed paths to the branch; no remote publication is included. Verification: - Focused Pascal VOC and COCO format tests: 179 passed, 5 warnings. - Staged merge diff check passed; no unmerged paths remained; reviewed merge tree 49df6c7. Residual limits: - Full remediation gates remain to be run after finding intake. - The test run emitted one pure-NumPy fallback warning and four deprecation warnings. --- Co-authored-by: Codex <codex@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In-memory dataset exports ignore a
Falseresult fromcv2.imwrite. An export can therefore return normally even though an image was never saved. Both the shared detection-image exporter and classification folder exporter now raiseOSErrorcontaining the destination path, matchingImageSink.Minimal reproduction (the destination image path already exists as a directory):
Before: returns
None, with no image file written. After: raisesOSError: Failed to save image to path: .../image.png.Motivation and Context
Report incomplete exports at the point of failure, so users can correct the destination instead of discovering missing training images later.
Changes Made
save_dataset_imagesandClassificationDataset.as_folder_structure, and document the exception.Testing
Revalidated after merging current upstream
develop(893a9b1a) and preserving the fix under Unreleased.New regression cases against unmodified
develop: two failed withDID NOT RAISE OSError; both successful-write controls passed.MPLBACKEND=Agg .venv/bin/pytest src/ tests/ --cov=supervision --cov-report=term: 6260 passed, 1 skipped, 44 warnings, 94% coverage. This includes the integration test running the ordinary suite with OpenCV imports blocked..venv/bin/pre-commit run --all-files: all configured pre-commit hooks passed, including Ruff, docformatter, mypy and codespell.Tested on Python 3.12 with OpenCV headless 4.14.0.94.
Added/updated tests, and the full suite passes locally
Updated docs (docstrings / mkdocs entry) for new or changed public API
Added a changelog entry in
docs/changelog.mdunderUnreleased