Skip to content

feat(data): add __repr__ and describe() to OTXDataset for better debug#5849

Merged
leoll2 merged 2 commits into
open-edge-platform:developfrom
christianfaccio:feat/dataset-repr-describe-v2
May 5, 2026
Merged

feat(data): add __repr__ and describe() to OTXDataset for better debug#5849
leoll2 merged 2 commits into
open-edge-platform:developfrom
christianfaccio:feat/dataset-repr-describe-v2

Conversation

@christianfaccio
Copy link
Copy Markdown
Contributor

@christianfaccio christianfaccio commented Mar 22, 2026

Summary

Add __repr__ and describe() methods to the OTXDataset base class for improved debuggability.

Currently, printing an OTXDataset instance shows an unhelpful default like <OTXDetectionDataset object at 0x7f...>. This PR adds:

  • __repr__: Returns a concise summary string, e.g. VisionDataset(num_samples=100, num_classes=5). Uses
    type(self).__name__ so subclasses automatically display the correct class name without needing to override.
  • describe(): Returns a dictionary with dataset metadata (class_name, num_samples, num_classes,
    label_names, has_transforms), useful for programmatic introspection during development and debugging.

Both methods are O(1) and rely on existing attributes (label_info, dm_subset, transforms).

How to test

uv run pytest library/tests/unit/data/dataset/test_base.py -v

All tests pass (12 pre-existing + 5 new).

@kprokofi
Copy link
Copy Markdown
Contributor

Please, update the branch with latest develop. Your changes can be merged

@christianfaccio christianfaccio changed the base branch from release/2.6 to develop April 21, 2026 17:47
@christianfaccio christianfaccio force-pushed the feat/dataset-repr-describe-v2 branch from 3ecca06 to 96cadf9 Compare April 21, 2026 18:05
@christianfaccio christianfaccio requested a review from a team as a code owner April 21, 2026 18:05
Copilot AI review requested due to automatic review settings April 21, 2026 18:05
@github-actions github-actions Bot added the TEST Any changes in tests label Apr 21, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds lightweight introspection utilities to the OTXDataset base class to make debugging and interactive inspection more informative.

Changes:

  • Implement OTXDataset.__repr__ to show class name, sample count, and class count.
  • Add OTXDataset.describe() to return a metadata dictionary for programmatic inspection.
  • Add unit tests covering the new __repr__/describe() behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
library/src/getitune/data/dataset/base.py Adds __repr__ and describe() to OTXDataset.
library/tests/unit/data/dataset/test_base.py Adds unit tests validating __repr__ and describe() output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread library/src/getitune/data/dataset/base.py
@christianfaccio
Copy link
Copy Markdown
Contributor Author

Hi @kprokofi, thanks for the review. I have rebased the branch onto the latest develop and updated the PR base accordingly. Given that the file moved from lib/src/otx/ to library/src/getitune/ during the refactor, I re-applied the change at the new path and ported the tests to match the new test style. I have also updated the PR description. Let me know if anything else is needed!

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@christianfaccio christianfaccio force-pushed the feat/dataset-repr-describe-v2 branch from 96cadf9 to fb63854 Compare April 23, 2026 18:23
@christianfaccio
Copy link
Copy Markdown
Contributor Author

Just renamed from OTXDataset to VisionDataset, tests passed locally.

@leoll2 leoll2 added this pull request to the merge queue May 5, 2026
Merged via the queue into open-edge-platform:develop with commit 0cbc5a4 May 5, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GSoC TEST Any changes in tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants