Repository navigation
[feat] add image dump (preview) feature - #13
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Preview dumping currently shares output paths in a way that can misreport split availability, and the new crop test depends on a non-repo file and has side effects instead of assertions.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (5)
Previously missed (4) — in code that hasn't changed since the last review.
src/prep/api/dataio.py:263
do_dump()writes preview files directly under the split output directory (the same pathscan_splits()uses to decide whether a split has been processed). If a user runs with--save-previewwhile saving is skipped (e.g., non-interactive mode), the presence of preview images will makeppls/status reporting incorrectly mark that split as available. Consider writing previews under a separate directory (e.g.<dataset_dir>/_preview/<split>/...) that does not overlap the dataset save path.
dump_dir = self.default_save_path(
pipeline, as_parquet=False, id_override=id_override
)
dump_dir.mkdir(parents=True, exist_ok=True)
tests/api/test_dataio.py:166
- This test assumes previews are written under the split directory. If
do_dump()is changed to write under a dedicated_preview/<split>directory (to avoid confusing status scanning and save paths), update the expected dump location accordingly.
This issue also appears on line 184 of the same file.
dump_dir = tmp_path / "cls" / "demo" / "train"
assert sorted(p.name for p in dump_dir.iterdir()) == [
tests/api/test_dataio.py:219
- This assertion assumes previews are written under
<fmt>/<id>/<split>/.... If previews are moved under<fmt>/<id>/_preview/<split>/..., update the expected location for theid_overridecase.
assert [p.name for p in (tmp_path / "cls" / "alias" / "train").iterdir()] == [
"000000_00.png"
]
src/prep/api/load.py:121
load_file()usespath.suffixwithout normalizing case, so files likeDATA.CSVwill raiseUnsupported file formateven though they’re valid. Normalizing tolower()avoids surprising failures on case-preserving file systems.
if path.suffix not in _FORMATS:
raise ValueError(f"Unsupported file format: {path.suffix!r}")
return load_dataset(_FORMATS[path.suffix], data_files=[str(path)], split="train")
tests/api/test_dataio.py:185
- This test assumes previews are written under the split directory. If
do_dump()is changed to write under a dedicated_preview/<split>directory (to avoid confusing status scanning and save paths), update the expected dump location accordingly.
dump_dir = tmp_path / "sft" / "demo" / "train"
assert sorted(p.name for p in dump_dir.iterdir()) == [
- Files reviewed: 12/12 changed files
- Comments generated: 2
- Review effort level: Lite
Comment on lines
+21
to
+24
| @pytest.fixture | ||
| def real_image_path() -> Path: | ||
| return Path("in/test.jpg") | ||
|
|
Comment on lines
+66
to
+81
| def test_real_case(self, real_image_path: Path) -> None: | ||
| try: | ||
| img = Image.open(real_image_path) | ||
| except Exception as e: | ||
| pytest.skip(f"Real image case not available {real_image_path}: {e}") | ||
|
|
||
| crop_black_border(img).save( | ||
| real_image_path.with_name( | ||
| real_image_path.stem + "_cropped" + real_image_path.suffix | ||
| ) | ||
| ) | ||
| crop_black_columns(img).save( | ||
| real_image_path.with_name( | ||
| real_image_path.stem + "_cropped_columns" + real_image_path.suffix | ||
| ) | ||
| ) |
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.
Before submitting
Changes
--save-preview/SAVE_PREVIEW, default0): saves images from the first N formatted samples to the default save path so output blobs can be visually inspectedOutputActions.do_dump()writes preview files named<row>_<idx>.<ext>src/prep/api/load.py