Skip to content

refactor: update custom validator definition#250

Merged
ktro2828 merged 2 commits into
mainfrom
refactor/custom-validator
Jan 23, 2026
Merged

refactor: update custom validator definition#250
ktro2828 merged 2 commits into
mainfrom
refactor/custom-validator

Conversation

@ktro2828

Copy link
Copy Markdown
Collaborator

What

This pull request refactors the implementation and usage of the impossible_empty validator across multiple schema table classes to improve consistency and correctness. The validator is now a callable class instance rather than a plain function, and its usage is updated throughout the codebase. Additionally, some minor improvements are made to how tuple validators are structured for certain fields.

Validator refactoring and usage updates:

  • Refactored impossible_empty from a function to a callable class (_ImpossibleEmptyValidator) and updated all schema table fields to use impossible_empty() instead of passing the function directly. This ensures correct validator behavior and consistency across all dataclasses. [1] [2]
  • Updated all relevant fields in schema table classes (such as CalibratedSensor, Instance, Keypoint, LidarSeg, Map, ObjectAnn, Sample, SampleAnnotation, SampleData, Scene, and SurfaceAnn) to use the new impossible_empty() validator invocation. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

Validator tuple structure improvements:

  • Simplified tuple structure for score and uncertainty field validators in AutolabelModel to use a flat tuple of validators, improving readability and correctness.

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Copilot AI review requested due to automatic review settings January 23, 2026 09:32
@github-actions github-actions Bot added the refactor Refactoring code or increasing performance label Jan 23, 2026

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 refactors the impossible_empty validator from a plain function to a callable class instance, ensuring consistent validator usage across all schema table classes. The change improves the correctness of validator behavior by making impossible_empty a factory function that returns validator instances.

Changes:

  • Converted impossible_empty to a factory function that returns _ImpossibleEmptyValidator instances
  • Updated all schema table fields to use impossible_empty() with parentheses instead of passing the function directly
  • Simplified validator tuple structure in AutolabelModel by removing unnecessary nested lists

Reviewed changes

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

Show a summary per file
File Description
t4_devkit/schema/tables/base.py Refactored impossible_empty to a factory function returning _ImpossibleEmptyValidator class instances
t4_devkit/schema/tables/calibrated_sensor.py Updated sensor_token field to use impossible_empty()
t4_devkit/schema/tables/instance.py Updated category_token field to use impossible_empty()
t4_devkit/schema/tables/keypoint.py Updated sample_data_token, instance_token, and category_tokens fields to use impossible_empty()
t4_devkit/schema/tables/lidarseg.py Updated sample_data_token field to use impossible_empty()
t4_devkit/schema/tables/map.py Updated log_tokens field to use impossible_empty()
t4_devkit/schema/tables/object_ann.py Updated sample_data_token, instance_token, category_token, and attribute_tokens fields to use impossible_empty()
t4_devkit/schema/tables/sample.py Updated scene_token field to use impossible_empty()
t4_devkit/schema/tables/sample_annotation.py Updated sample_token, instance_token, attribute_tokens, and visibility_token fields to use impossible_empty()
t4_devkit/schema/tables/sample_data.py Updated ego_pose_token and calibrated_sensor_token fields to use impossible_empty()
t4_devkit/schema/tables/scene.py Updated log_token, first_sample_token, and last_sample_token fields to use impossible_empty()
t4_devkit/schema/tables/surface_ann.py Updated sample_data_token and category_token fields to use impossible_empty()
t4_devkit/schema/tables/autolabel_metadata.py Simplified validator tuple structure for score and uncertainty fields

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

Comment thread t4_devkit/schema/tables/base.py Outdated
@github-actions

github-actions Bot commented Jan 23, 2026

Copy link
Copy Markdown
Contributor

☂️ Python Coverage

current status: ❌

Overall Coverage

Lines Covered Coverage Threshold Status
4125 3417 83% 50% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
t4_devkit/schema/tables/autolabel_metadata.py 100% 🟢
t4_devkit/schema/tables/base.py 97% 🟢
t4_devkit/schema/tables/calibrated_sensor.py 100% 🟢
t4_devkit/schema/tables/instance.py 100% 🟢
t4_devkit/schema/tables/keypoint.py 100% 🟢
t4_devkit/schema/tables/lidarseg.py 100% 🟢
t4_devkit/schema/tables/map.py 100% 🟢
t4_devkit/schema/tables/object_ann.py 86% 🟢
t4_devkit/schema/tables/sample.py 100% 🟢
t4_devkit/schema/tables/sample_annotation.py 100% 🟢
t4_devkit/schema/tables/sample_data.py 100% 🟢
t4_devkit/schema/tables/scene.py 100% 🟢
t4_devkit/schema/tables/surface_ann.py 73% 🔴
TOTAL 97% 🔴

updated for commit: e846972 by action🐍

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ktro2828 ktro2828 merged commit 9c0cd60 into main Jan 23, 2026
4 of 5 checks passed
@ktro2828 ktro2828 deleted the refactor/custom-validator branch January 23, 2026 09:36
mojomex added a commit that referenced this pull request Jan 30, 2026
* chore(deps): restrict rerun-sdk to versions >=0.20.0,<0.28.0 (#248)

* Bump version from 0.5.2 to 0.5.3 (#247)

* Bump version from 0.5.2 to 0.5.3

* Pin rerun-sdk dependency to version 0.20.0

* refactor: update custom validator definition (#250)

* refactor: update custom validator definition

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* Update t4_devkit/schema/tables/base.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: modity type of size to tuple[int, int] (#251)

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* fix: abstract away category indexing differences

Semseg and non-semseg datasets behave differently (position-based vs. explicit indexing).
Now computing index field in case position-based indexing is used.

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* fix(rendering): don't fail when map is not present

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* fix(rendering): fix iteration freezing when skipping  a pointcloud without lidarseg file

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* feat(rendering): auto-enable SEGMENTATION coloring when lidarseg is available

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* docs: checkmark for semseg viz

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* fix(rendering): fix wrongly named `color_mode` args

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* refactor(compatibility): move to schema package

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

---------

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Co-authored-by: Kotaro Uetake <60615504+ktro2828@users.noreply.github.com>
Co-authored-by: Samrat Thapa <38401989+SamratThapa120@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ktro2828 added a commit that referenced this pull request Jan 30, 2026
* chore(deps): restrict rerun-sdk to versions >=0.20.0,<0.28.0 (#248)

* Bump version from 0.5.2 to 0.5.3 (#247)

* Bump version from 0.5.2 to 0.5.3

* Pin rerun-sdk dependency to version 0.20.0

* refactor: update custom validator definition (#250)

* refactor: update custom validator definition

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* Update t4_devkit/schema/tables/base.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: modity type of size to tuple[int, int] (#251)

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* fix: abstract away category indexing differences

Semseg and non-semseg datasets behave differently (position-based vs. explicit indexing).
Now computing index field in case position-based indexing is used.

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* fix(rendering): don't fail when map is not present

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* fix(rendering): fix iteration freezing when skipping  a pointcloud without lidarseg file

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* feat(rendering): auto-enable SEGMENTATION coloring when lidarseg is available

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* docs: checkmark for semseg viz

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* fix(rendering): fix wrongly named `color_mode` args

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* refactor(compatibility): move to schema package

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

---------

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Co-authored-by: Kotaro Uetake <60615504+ktro2828@users.noreply.github.com>
Co-authored-by: Samrat Thapa <38401989+SamratThapa120@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ktro2828 added a commit that referenced this pull request Jan 30, 2026
* chore(deps): restrict rerun-sdk to versions >=0.20.0,<0.28.0 (#248)

* Bump version from 0.5.2 to 0.5.3 (#247)

* Bump version from 0.5.2 to 0.5.3

* Pin rerun-sdk dependency to version 0.20.0

* refactor: update custom validator definition (#250)

* refactor: update custom validator definition

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* Update t4_devkit/schema/tables/base.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: modity type of size to tuple[int, int] (#251)

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* fix: abstract away category indexing differences

Semseg and non-semseg datasets behave differently (position-based vs. explicit indexing).
Now computing index field in case position-based indexing is used.

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* fix(rendering): don't fail when map is not present

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* fix(rendering): fix iteration freezing when skipping  a pointcloud without lidarseg file

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* feat(rendering): auto-enable SEGMENTATION coloring when lidarseg is available

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* docs: checkmark for semseg viz

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* fix(rendering): fix wrongly named `color_mode` args

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* refactor(compatibility): move to schema package

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

---------

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Co-authored-by: Kotaro Uetake <60615504+ktro2828@users.noreply.github.com>
Co-authored-by: Samrat Thapa <38401989+SamratThapa120@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ktro2828 added a commit that referenced this pull request Feb 2, 2026
* feat: add support of rendering segmentation pointcloud

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* feat: separate lidarseg method

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* chore(viewer): lidarseg tweaks (#256)

* chore(deps): restrict rerun-sdk to versions >=0.20.0,<0.28.0 (#248)

* Bump version from 0.5.2 to 0.5.3 (#247)

* Bump version from 0.5.2 to 0.5.3

* Pin rerun-sdk dependency to version 0.20.0

* refactor: update custom validator definition (#250)

* refactor: update custom validator definition

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* Update t4_devkit/schema/tables/base.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: modity type of size to tuple[int, int] (#251)

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* fix: abstract away category indexing differences

Semseg and non-semseg datasets behave differently (position-based vs. explicit indexing).
Now computing index field in case position-based indexing is used.

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* fix(rendering): don't fail when map is not present

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* fix(rendering): fix iteration freezing when skipping  a pointcloud without lidarseg file

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* feat(rendering): auto-enable SEGMENTATION coloring when lidarseg is available

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* docs: checkmark for semseg viz

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* fix(rendering): fix wrongly named `color_mode` args

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

* refactor(compatibility): move to schema package

Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>

---------

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Co-authored-by: Kotaro Uetake <60615504+ktro2828@users.noreply.github.com>
Co-authored-by: Samrat Thapa <38401989+SamratThapa120@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* refactor: remove lidarseg command from t4viz

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* refactor: replace lidarseg existence checke

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* feat: add support of rendering segmentation pointcloud

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* fix: resolve invalid usage of future submitting and enable to raise exceptions

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* docs: add visualization sample

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

* refactor: remove RerunViewer.render_pointcloud(...)

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

---------

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: Max SCHMELLER <max.schmeller@tier4.jp>
Co-authored-by: Max Schmeller <6088931+mojomex@users.noreply.github.com>
Co-authored-by: Samrat Thapa <38401989+SamratThapa120@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactoring code or increasing performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants