Skip to content

refactor: add ViewerBuilder#193

Merged
ktro2828 merged 3 commits into
mainfrom
feat/viewer/builder-pattern
Oct 2, 2025
Merged

refactor: add ViewerBuilder#193
ktro2828 merged 3 commits into
mainfrom
feat/viewer/builder-pattern

Conversation

@ktro2828

@ktro2828 ktro2828 commented Sep 30, 2025

Copy link
Copy Markdown
Collaborator

What

This pull request refactors the viewer initialization and configuration logic to use a new builder pattern, improving flexibility and maintainability. The changes introduce a ViewerBuilder and ViewerConfig class, update documentation and usage examples, and remove legacy configuration code from RerunViewer. The rendering helper functions and viewer methods are updated to use the new configuration approach.

Viewer Initialization and Configuration Refactor:

  • Introduced ViewerBuilder and ViewerConfig classes to encapsulate viewer setup, replacing direct instantiation and configuration of RerunViewer. This enables a more flexible and composable API for specifying spatial views, labels, and streetmap settings. (t4_devkit/viewer/builder.py, t4_devkit/viewer/config.py, t4_devkit/viewer/__init__.py) [1] [2] [3]
  • Refactored RerunViewer to accept a ViewerConfig object, removing legacy arguments (cameras, with_3d, etc.) and related methods (with_labels, with_global_origin). Viewer setup and blueprint construction now rely on the configuration object. (t4_devkit/viewer/viewer.py) [1] [2] [3]
  • Updated viewer rendering methods to use configuration properties and improved entity path formatting, ensuring consistent logging and rendering for both 2D and 3D spaces. (t4_devkit/viewer/viewer.py) [1] [2] [3]

Documentation and Example Updates:

  • Updated documentation and code samples to demonstrate usage of the new ViewerBuilder API, replacing direct RerunViewer construction and legacy arguments. (docs/tutorials/render.md) [1] [2]

Rendering Helper Function Updates:

  • Refactored helper functions in t4_devkit/helper/rendering.py to use ViewerBuilder for viewer creation, removing logic for legacy configuration arguments and improving annotation and streetmap setup. (t4_devkit/helper/rendering.py) [1] [2] [3] [4]

Usage

from t4_devkit.viewer import ViewerBuilder

viewer = (
    ViewerBuilder()
    .with_spatial3d()
    .with_spatial2d(cameras=["CAM_FRONT", "CAM_BACK"])
    .with_labels(label2id={"car": 1, "pedestrian": 2})
    .build(app_id="foo")
)

viewer.render_box3ds(seconds, box3ds)

@github-actions github-actions Bot added ci Continuous Integration (CI) processes and testing new-feature New feature or request labels Sep 30, 2025
@github-actions

github-actions Bot commented Sep 30, 2025

Copy link
Copy Markdown
Contributor

☂️ Python Coverage

current status: ❌

Overall Coverage

Lines Covered Coverage Threshold Status
2716 2084 77% 50% 🟢

New Files

File Coverage Status
t4_devkit/viewer/builder.py 88% 🟢
t4_devkit/viewer/config.py 97% 🟢
TOTAL 93% 🟢

Modified Files

File Coverage Status
t4_devkit/helper/rendering.py 15% 🔴
t4_devkit/viewer/init.py 100% 🟢
t4_devkit/viewer/viewer.py 88% 🟢
TOTAL 68% 🔴

updated for commit: b4024eb by action🐍

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Sep 30, 2025
@ktro2828 ktro2828 changed the title feat: add ViewerBuilder refactor: add ViewerBuilder Sep 30, 2025
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>

docs: update tutorial document

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

feat: adopt builder pattern using ViewerBuilder

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
@ktro2828 ktro2828 force-pushed the feat/viewer/builder-pattern branch from 8a0c425 to 337ccde Compare October 2, 2025 02:27
@ktro2828 ktro2828 marked this pull request as ready for review October 2, 2025 02:34
Copilot AI review requested due to automatic review settings October 2, 2025 02:34

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 viewer initialization and configuration logic by introducing a builder pattern to improve flexibility and maintainability. The changes replace direct RerunViewer instantiation with a new ViewerBuilder and ViewerConfig approach, enabling more composable viewer configuration.

  • Introduces ViewerBuilder and ViewerConfig classes for flexible viewer setup
  • Refactors RerunViewer to accept configuration objects instead of direct parameters
  • Updates documentation and helper functions to use the new builder pattern

Reviewed Changes

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

Show a summary per file
File Description
t4_devkit/viewer/config.py Defines ViewerConfig class and entity formatting utility
t4_devkit/viewer/builder.py Implements ViewerBuilder for fluent viewer configuration
t4_devkit/viewer/viewer.py Refactors RerunViewer to use configuration-based initialization
t4_devkit/viewer/__init__.py Exports new builder and config modules
t4_devkit/helper/rendering.py Updates helper functions to use ViewerBuilder
tests/viewer/conftest.py Updates test fixtures to use new builder pattern
tests/viewer/test_viewer.py Updates test to include frame_id parameter
docs/tutorials/render.md Updates documentation with new builder API examples

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

Comment thread t4_devkit/viewer/viewer.py Outdated
@ktro2828 ktro2828 force-pushed the feat/viewer/builder-pattern branch from 37c3af3 to 0667e45 Compare October 2, 2025 02:58
@ktro2828 ktro2828 requested a review from Copilot October 2, 2025 02:59

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

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


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

Comment thread t4_devkit/viewer/viewer.py Outdated
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
@ktro2828 ktro2828 force-pushed the feat/viewer/builder-pattern branch from 0667e45 to b1e945e Compare October 2, 2025 03:00
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
@ktro2828 ktro2828 merged commit b0077d3 into main Oct 2, 2025
4 of 5 checks passed
@ktro2828 ktro2828 deleted the feat/viewer/builder-pattern branch October 2, 2025 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continuous Integration (CI) processes and testing documentation Improvements or additions to documentation new-feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants