Skip to content

chore: sync table definition with tier4_perception_dataset#185

Merged
SamratThapa120 merged 16 commits into
mainfrom
chore/sync_table_definition
Sep 8, 2025
Merged

chore: sync table definition with tier4_perception_dataset#185
SamratThapa120 merged 16 commits into
mainfrom
chore/sync_table_definition

Conversation

@SamratThapa120

@SamratThapa120 SamratThapa120 commented Sep 1, 2025

Copy link
Copy Markdown
Contributor

This pull request introduces changes to sync the table definitions in tier4_perception_dataset with t4-devkit. Only remaining sync is for the lidarseg table, which is addressed in PR #184

Autolabeling metadata support

  • Added the AutolabelModel type to the schema, including its definition in documentation (docs/schema/table.md) and implementation in code (t4_devkit/schema/tables/autolabel_metadata.py). This type tracks model name, score, and uncertainty for autolabeling. [1] [2] [3]
  • Introduced an autolabel_metadata field to SampleAnnotation, SampleData, ObjectAnn, and SurfaceAnn tables, allowing storage of autolabeling model information wherever automatic_annotation is used. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Category and annotation field extensions

  • Added has_orientation and has_number fields to the Category schema and documentation, enabling category-level control over the presence of orientation and number fields in object annotations. [1] [2]
  • Added orientation and number fields to the ObjectAnn schema and documentation, supporting specialized annotation for traffic light arrows and numeric traffic lights, gated by category settings. [1] [2] [3]

Documentation updates

  • Updated docs/schema/table.md to document all new fields, types, and their usage, including detailed explanations for AutolabelModel, autolabel_metadata, has_orientation, has_number, orientation, and number. [1] [2] [3] [4] [5] [6] [7]

Codebase integration

  • Registered the new autolabel_metadata module in the schema package and imported AutolabelModel into all affected schema tables to enable type checking and conversion. [1] [2] [3] [4] [5]

Validation and conversion logic

  • Implemented validation and conversion logic for the new fields in all affected schema classes, ensuring correct handling of lists of AutolabelModel instances and optional fields. [1] [2] [3] [4] [5]

@github-actions github-actions Bot added chore documentation Improvements or additions to documentation labels Sep 1, 2025
@github-actions github-actions Bot added the ci Continuous Integration (CI) processes and testing label Sep 2, 2025
@SamratThapa120 SamratThapa120 marked this pull request as ready for review September 2, 2025 02:36
Copilot AI review requested due to automatic review settings September 2, 2025 02:36

Copilot AI 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.

Pull Request Overview

This PR syncs table definitions with tier4_perception_dataset by introducing autolabeling metadata support and category-specific annotation field extensions. The changes enable tracking of ML model information for automatically generated annotations and support specialized fields for traffic light annotations.

  • Added AutolabelModel type and autolabel_metadata fields to support tracking of autolabeling model information
  • Extended Category schema with has_orientation and has_number flags to control presence of specialized annotation fields
  • Added orientation and number fields to ObjectAnn for traffic light arrow directions and numeric displays

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
t4_devkit/schema/tables/autolabel_metadata.py New module defining AutolabelModel dataclass for autolabeling metadata
t4_devkit/schema/tables/__init__.py Added import for new autolabel metadata module
t4_devkit/schema/tables/category.py Added has_orientation and has_number optional boolean fields
t4_devkit/schema/tables/object_ann.py Added orientation, number, and autolabel_metadata fields with validation
t4_devkit/schema/tables/sample_annotation.py Added autolabel_metadata field with validation logic
t4_devkit/schema/tables/sample_data.py Added autolabel_metadata field with validation logic
t4_devkit/schema/tables/surface_ann.py Added autolabel_metadata field with validation logic
docs/schema/table.md Updated documentation to describe all new fields and AutolabelModel type
tests/schema/conftest.py Updated test fixtures to include new fields with sample data

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ktro2828 ktro2828 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@SamratThapa120 Thank you for following up! I left some comments please take a look.

Comment thread docs/schema/table.md Outdated
Comment thread t4_devkit/schema/tables/object_ann.py Outdated
Comment on lines +98 to +102
converter=lambda x: [
AutolabelModel(**model) if isinstance(model, dict) else model for model in x
]
if isinstance(x, list)
else x,

@ktro2828 ktro2828 Sep 2, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[WANT] Can you define this conversion function in annotation_metadata.py like below?
This function can be reused in the other schema field conversions.

def to_autolabel_model(x) -> AutolabelModel:
    // ...

Comment thread t4_devkit/schema/tables/object_ann.py Outdated
Comment thread t4_devkit/schema/tables/category.py Outdated
@ktro2828

ktro2828 commented Sep 2, 2025

Copy link
Copy Markdown
Collaborator

[MEMO] I encountered errors while running pytest, and they were fixed by the following changes:

───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: t4_devkit/schema/tables/autolabel_metadata.py
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  27   │         default=None,
  28   │         validator=validators.optional(
  29 ~ │             (validators.instance_of(float), validators.ge(0.0), validators.le(1.0))
  30   │         ),
  31   │     )
 ...   │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ 8< ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
  484950 ~ │ @define(slots=False)
  51   │ class AutolabelMixin:
  52"""Mixin class for schema tables that use autolabel metadata with automatic annotation."""
  5354 ~ │     automatic_annotation: bool = field(
  55 ~ │         default=False, validator=validators.instance_of(bool), kw_only=True
  56 ~ │     )
  57   │     autolabel_metadata: list[AutolabelModel] | None = field(
  58   │         default=None,
 ...   │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ 8< ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
  61   │             validators.deep_iterable(validators.instance_of(AutolabelModel))
  62   │         ),
  63 + │         kw_only=True,
  64   │     )
  65   │ 
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: tests/schema/conftest.py
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  63"description": "",
  64"index": None,
  65 ~ │         "has_number": False,
  66 ~ │         "has_orientation": False,
  67   │     }
  68   │ 
 ...   │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ 8< ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
 181"next": "7b0ae1dae7531b7b917f403cb22259e6",
 182"prev": "",
 183 ~ │         "automatic_annotation": True,
 184"autolabel_metadata": [{"name": "centerpoint_v1.2", "score": 0.95, "uncertainty": 0.1}],
 185   │     }
 ...   │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ 8< ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
 321"bbox": [0, 408.0529355733727, 1920, 728.1832152454293],
 322"mask": {"size": [1920, 1280], "counts": "UFBQWzI='"},
 323 ~ │         "automatic_annotation": True,
 324"autolabel_metadata": [
 325   │             {"name": "yolo_v8_segmentation", "score": 0.87, "uncertainty": 0.15},
───────┴──────────────────────────────────────────────────────────────────────────────────
  • slots=True provides memory efficiency and faster attribute access, but it causes type-error because of field layout conflict if we define subclass with multiple classes defined by @define(slots=True).
  • validators must be hashable, so we need to set multiple validators by using tuple or validators.and_ instead of list.
  • Attrs has a strict rule: fields with default values cannot before fields without default values in the inheritance hierachy. To avoid error relevant to this rule, we need to set kw_only=True for fields with default values.

What are __slots__ in Python?

>>> class FooWithoutSlots:
...     """A class without slots"""
...     def __init__(self, n: int) -> None:
...             self.n = n
... 
>>> class FooWithSlots:
...     """A class with slots"""
...     __slots__ = ("n",)
...     def __init__(self, n: int) -> None:
...             self.n = n
... 
>>> foo1 = FooWithoutSlots(1)
>>> foo2 = FooWithSlots(1)
>>> 
>>> # FooWithoutSlots creates __dict__ every time when it is constructed, but FooWitSlots doesn't
>>> foo1.__dict__
{'n': 1}
>>> foo2.__dict__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'FooWithSlots' object has no attribute '__dict__'. Did you mean: '__dir__'?
>>> # instead of creating __dict__, __slots__ stores all attribute names 
>>> foo2.__slots__
('n',)
>>> 
>>> # Then nobody can add new attributes to the instance that has __slots__
>>> foo1.bar = 2  # OK
>>> foo2.bar = 2  # ERROR
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'FooWithSlots' object has no attribute 'bar'

@github-actions

github-actions Bot commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

☂️ Python Coverage

current status: ❌

Overall Coverage

Lines Covered Coverage Threshold Status
2676 2034 76% 50% 🟢

New Files

File Coverage Status
t4_devkit/schema/tables/autolabel_metadata.py 100% 🟢
TOTAL 100% 🟢

Modified Files

File Coverage Status
t4_devkit/schema/tables/init.py 100% 🟢
t4_devkit/schema/tables/category.py 100% 🟢
t4_devkit/schema/tables/object_ann.py 86% 🟢
t4_devkit/schema/tables/sample_annotation.py 100% 🟢
t4_devkit/schema/tables/sample_data.py 100% 🟢
t4_devkit/schema/tables/surface_ann.py 73% 🔴
TOTAL 93% 🔴

updated for commit: f6bd11a by action🐍

@SamratThapa120

Copy link
Copy Markdown
Contributor Author

@ktro2828 Thank you for your detailed comments. I have fixed the tests.
I will also add newer tests to improve code coverage soon.

@SamratThapa120

Copy link
Copy Markdown
Contributor Author

@ktro2828 I have added tests for t4_devkit/schema/tables/autolabel_metadata.py, The lack of coverage for object_ann.py and surface_ann.py predates this PR, and should be addressed separately.

@ktro2828 ktro2828 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@SamratThapa120 SamratThapa120 force-pushed the chore/sync_table_definition branch from 87cf840 to f6bd11a Compare September 8, 2025 03:56
@SamratThapa120 SamratThapa120 merged commit 0f2b28d into main Sep 8, 2025
5 checks passed
@SamratThapa120 SamratThapa120 deleted the chore/sync_table_definition branch September 8, 2025 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore ci Continuous Integration (CI) processes and testing documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants