Skip to content

Move DatasetExport into its own dataset_export.py module - #1631

Merged
MalteEbner merged 4 commits into
mainfrom
malte-lig-9972-move-dataset-export
Jul 13, 2026
Merged

Move DatasetExport into its own dataset_export.py module#1631
MalteEbner merged 4 commits into
mainfrom
malte-lig-9972-move-dataset-export

Conversation

@MalteEbner

@MalteEbner MalteEbner commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

What has changed and why

Move DatasetExport to its own file. Done via VSCode Refactor->move to new file + manual import/docstring updates.

Next steps:

  • Refactor tests to have TestDatasetExport and TestImageDatasetExport
  • add VideoFrameDatasetExport

How was it tested

existing unittests.

Relocate the generic DatasetExport base out of image_dataset_export.py into a
new dataset_export.py. image_dataset_export.py keeps the public ImageDatasetExport
and image_sample_to_image (so lightly_studio.export.image_dataset_export still
imports) and now imports DatasetExport from the new module.

Pure move, no behavior change. The only follow-on edit is retargeting the
COCOObjectDetectionOutput writer patch in the test to the module it now lives in.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MalteEbner
MalteEbner requested a review from a team as a code owner July 13, 2026 10:02
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a shared DatasetExport class for COCO, YOLOv8, captions, and segmentation exports, then makes ImageDatasetExport specialize it with image conversion logic for ImageSample values.

Changes

Dataset export pipeline

Layer / File(s) Summary
Shared export implementation
lightly_studio/src/lightly_studio/export/dataset_export.py
DatasetExport stores export context and delegates COCO, YOLOv8, captions, and segmentation serialization to labelformat outputs, with optional annotation collection filtering.
Image export specialization
lightly_studio/src/lightly_studio/export/image_dataset_export.py, lightly_studio/tests/export/test_image_dataset_export.py
ImageDatasetExport supplies image mapping for the shared exporter, and tests update mock targets to the new module.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ImageDatasetExport
  participant DatasetExport
  participant LabelformatInput
  participant LabelformatOutput
  ImageDatasetExport->>DatasetExport: initialize with image mapping strategy
  DatasetExport->>LabelformatInput: construct format-specific input
  DatasetExport->>LabelformatOutput: serialize selected samples and annotations
Loading

Possibly related PRs

Suggested reviewers: lukas-lightly, michal-lightly, horatiualmasan, jonaswurst, leonardorosaa

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
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.
Title check ✅ Passed The title clearly matches the main change: moving DatasetExport into a new dataset_export.py module.
Description check ✅ Passed The description covers the change and testing, but it omits the required CHANGELOG.md section from the template.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch malte-lig-9972-move-dataset-export

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lightly_studio/src/lightly_studio/export/dataset_export.py`:
- Around line 70-71: Update the Raises documentation for the method accepting
annotation_collection_id so it refers to the annotation collection ID rather
than a nonexistent name, and accurately states the condition under which
ValueError is raised.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 17c1114a-f62f-473f-b3c5-59473ca161db

📥 Commits

Reviewing files that changed from the base of the PR and between 378f303 and 7b75dcd.

📒 Files selected for processing (3)
  • lightly_studio/src/lightly_studio/export/dataset_export.py
  • lightly_studio/src/lightly_studio/export/image_dataset_export.py
  • lightly_studio/tests/export/test_image_dataset_export.py

Comment thread lightly_studio/src/lightly_studio/export/dataset_export.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lightly_studio/src/lightly_studio/export/dataset_export.py`:
- Around line 20-23: Remove the circular dependency between dataset_export.py
and image_dataset_export.py by relocating the shared constants
DEFAULT_EXPORT_FILENAME, YOLO_DATASET_CONFIG_FILENAME, and YOLO_DEFAULT_SPLIT
into dataset_export.py or a neutral constants module. Update both export modules
to import these values from their new owner while preserving existing behavior
and public references.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 70b51fc7-5c7f-49de-a721-9dfa4b957723

📥 Commits

Reviewing files that changed from the base of the PR and between 7b75dcd and 81d9d3f.

📒 Files selected for processing (2)
  • lightly_studio/src/lightly_studio/export/dataset_export.py
  • lightly_studio/src/lightly_studio/export/image_dataset_export.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • lightly_studio/src/lightly_studio/export/image_dataset_export.py

Comment thread lightly_studio/src/lightly_studio/export/dataset_export.py Outdated
Move the export-filename constants into dataset_export.py (their only user is
DatasetExport) and drop the back-import from image_dataset_export.py, resolving
the module-initialization cycle. Remove the stale ValueError Raises entry from
to_coco_object_detections (the method has no such parameter and raises no
ValueError). Retarget the writer patch in the test to dataset_export.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MalteEbner

Copy link
Copy Markdown
Contributor Author

/review

@horatiualmasan horatiualmasan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@MalteEbner
MalteEbner added this pull request to the merge queue Jul 13, 2026
Merged via the queue into main with commit c122f73 Jul 13, 2026
23 checks passed
@MalteEbner
MalteEbner deleted the malte-lig-9972-move-dataset-export branch July 13, 2026 11:28
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.

2 participants