From 7f09d00e8c6d3ae1ec3add241cef57ad56417b7e Mon Sep 17 00:00:00 2001 From: ktro2828 Date: Tue, 2 Sep 2025 15:12:24 +0900 Subject: [PATCH 1/2] ci: update to run CLI on CI workflow Signed-off-by: ktro2828 --- .github/workflows/build-and-test.yaml | 8 +++++ tests/conftest.py | 5 +++ tests/lanelet/test_parser.py | 5 ++- .../{ => t4dataset}/annotation/attribute.json | 0 .../annotation/calibrated_sensor.json | 0 .../{ => t4dataset}/annotation/category.json | 0 .../{ => t4dataset}/annotation/ego_pose.json | 0 .../{ => t4dataset}/annotation/instance.json | 0 .../{ => t4dataset}/annotation/log.json | 0 .../{ => t4dataset}/annotation/map.json | 0 .../annotation/object_ann.json | 0 .../{ => t4dataset}/annotation/sample.json | 0 .../annotation/sample_annotation.json | 0 .../annotation/sample_data.json | 0 .../{ => t4dataset}/annotation/scene.json | 0 .../{ => t4dataset}/annotation/sensor.json | 0 .../annotation/surface_ann.json | 0 .../annotation/vehicle_state.json | 0 .../annotation/visibility.json | 0 .../{ => t4dataset}/data/CAM_BACK/001.jpg | Bin .../{ => t4dataset}/data/CAM_BACK/002.jpg | Bin .../{ => t4dataset}/data/CAM_BACK/003.jpg | Bin .../{ => t4dataset}/data/CAM_FRONT/001.jpg | Bin .../{ => t4dataset}/data/CAM_FRONT/002.jpg | Bin .../{ => t4dataset}/data/CAM_FRONT/003.jpg | Bin .../data/LIDAR_TOP/001.pcd.bin | Bin .../data/LIDAR_TOP/002.pcd.bin | Bin .../data/LIDAR_TOP/003.pcd.bin | Bin .../{ => t4dataset}/map/lanelet2_map.osm | 0 tests/sample/{ => t4dataset}/status.json | 0 tests/test_tier4.py | 30 +++++++++--------- tests/viewer/test_viewer.py | 5 ++- 32 files changed, 32 insertions(+), 21 deletions(-) rename tests/sample/{ => t4dataset}/annotation/attribute.json (100%) rename tests/sample/{ => t4dataset}/annotation/calibrated_sensor.json (100%) rename tests/sample/{ => t4dataset}/annotation/category.json (100%) rename tests/sample/{ => t4dataset}/annotation/ego_pose.json (100%) rename tests/sample/{ => t4dataset}/annotation/instance.json (100%) rename tests/sample/{ => t4dataset}/annotation/log.json (100%) rename tests/sample/{ => t4dataset}/annotation/map.json (100%) rename tests/sample/{ => t4dataset}/annotation/object_ann.json (100%) rename tests/sample/{ => t4dataset}/annotation/sample.json (100%) rename tests/sample/{ => t4dataset}/annotation/sample_annotation.json (100%) rename tests/sample/{ => t4dataset}/annotation/sample_data.json (100%) rename tests/sample/{ => t4dataset}/annotation/scene.json (100%) rename tests/sample/{ => t4dataset}/annotation/sensor.json (100%) rename tests/sample/{ => t4dataset}/annotation/surface_ann.json (100%) rename tests/sample/{ => t4dataset}/annotation/vehicle_state.json (100%) rename tests/sample/{ => t4dataset}/annotation/visibility.json (100%) rename tests/sample/{ => t4dataset}/data/CAM_BACK/001.jpg (100%) rename tests/sample/{ => t4dataset}/data/CAM_BACK/002.jpg (100%) rename tests/sample/{ => t4dataset}/data/CAM_BACK/003.jpg (100%) rename tests/sample/{ => t4dataset}/data/CAM_FRONT/001.jpg (100%) rename tests/sample/{ => t4dataset}/data/CAM_FRONT/002.jpg (100%) rename tests/sample/{ => t4dataset}/data/CAM_FRONT/003.jpg (100%) rename tests/sample/{ => t4dataset}/data/LIDAR_TOP/001.pcd.bin (100%) rename tests/sample/{ => t4dataset}/data/LIDAR_TOP/002.pcd.bin (100%) rename tests/sample/{ => t4dataset}/data/LIDAR_TOP/003.pcd.bin (100%) rename tests/sample/{ => t4dataset}/map/lanelet2_map.osm (100%) rename tests/sample/{ => t4dataset}/status.json (100%) diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index 93561b4..b0ca3be 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -46,6 +46,14 @@ jobs: if: ${{ steps.is-changed.outputs.changes == 'true'}} run: uv run pytest --cov-report xml:coverage.xml --cov=t4_devkit + - name: Run CLIs + if: ${{ steps.is-changed.outputs.changes == 'true'}} + run: | + uv run t4viz scene ./tests/sample/t4dataset + uv run t4viz instance ./tests/sample/t4dataset 90f0c98d1a040d5360847f576c5528f8 + uv run t4viz pointcloud ./tests/sample/t4dataset + uv run t4sanity ./tests/sample -iw + - name: Get test coverage if: ${{ steps.is-changed.outputs.changes == 'true'}} && ${{ matrix.python-version == '3.10' }} uses: orgoro/coverage@v3.1 diff --git a/tests/conftest.py b/tests/conftest.py index e3cd6a3..5a56b36 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -308,3 +308,8 @@ def dummy_camera_calibration() -> tuple[tuple[int, int], NDArrayFloat]: ) return img_size, intrinsic + + +@pytest.fixture(scope="session") +def dummy_lanelet_path() -> str: + return "tests/sample/t4dataset/map/lanelet2_map.osm" diff --git a/tests/lanelet/test_parser.py b/tests/lanelet/test_parser.py index 20eceee..2c88ed6 100644 --- a/tests/lanelet/test_parser.py +++ b/tests/lanelet/test_parser.py @@ -3,7 +3,6 @@ from t4_devkit.lanelet import LaneletParser -def test_lanelet_parser() -> None: +def test_lanelet_parser(dummy_lanelet_path) -> None: """Test `LaneletParser`.""" - lanelet_path = "tests/sample/map/lanelet2_map.osm" - _ = LaneletParser(lanelet_path) + _ = LaneletParser(dummy_lanelet_path) diff --git a/tests/sample/annotation/attribute.json b/tests/sample/t4dataset/annotation/attribute.json similarity index 100% rename from tests/sample/annotation/attribute.json rename to tests/sample/t4dataset/annotation/attribute.json diff --git a/tests/sample/annotation/calibrated_sensor.json b/tests/sample/t4dataset/annotation/calibrated_sensor.json similarity index 100% rename from tests/sample/annotation/calibrated_sensor.json rename to tests/sample/t4dataset/annotation/calibrated_sensor.json diff --git a/tests/sample/annotation/category.json b/tests/sample/t4dataset/annotation/category.json similarity index 100% rename from tests/sample/annotation/category.json rename to tests/sample/t4dataset/annotation/category.json diff --git a/tests/sample/annotation/ego_pose.json b/tests/sample/t4dataset/annotation/ego_pose.json similarity index 100% rename from tests/sample/annotation/ego_pose.json rename to tests/sample/t4dataset/annotation/ego_pose.json diff --git a/tests/sample/annotation/instance.json b/tests/sample/t4dataset/annotation/instance.json similarity index 100% rename from tests/sample/annotation/instance.json rename to tests/sample/t4dataset/annotation/instance.json diff --git a/tests/sample/annotation/log.json b/tests/sample/t4dataset/annotation/log.json similarity index 100% rename from tests/sample/annotation/log.json rename to tests/sample/t4dataset/annotation/log.json diff --git a/tests/sample/annotation/map.json b/tests/sample/t4dataset/annotation/map.json similarity index 100% rename from tests/sample/annotation/map.json rename to tests/sample/t4dataset/annotation/map.json diff --git a/tests/sample/annotation/object_ann.json b/tests/sample/t4dataset/annotation/object_ann.json similarity index 100% rename from tests/sample/annotation/object_ann.json rename to tests/sample/t4dataset/annotation/object_ann.json diff --git a/tests/sample/annotation/sample.json b/tests/sample/t4dataset/annotation/sample.json similarity index 100% rename from tests/sample/annotation/sample.json rename to tests/sample/t4dataset/annotation/sample.json diff --git a/tests/sample/annotation/sample_annotation.json b/tests/sample/t4dataset/annotation/sample_annotation.json similarity index 100% rename from tests/sample/annotation/sample_annotation.json rename to tests/sample/t4dataset/annotation/sample_annotation.json diff --git a/tests/sample/annotation/sample_data.json b/tests/sample/t4dataset/annotation/sample_data.json similarity index 100% rename from tests/sample/annotation/sample_data.json rename to tests/sample/t4dataset/annotation/sample_data.json diff --git a/tests/sample/annotation/scene.json b/tests/sample/t4dataset/annotation/scene.json similarity index 100% rename from tests/sample/annotation/scene.json rename to tests/sample/t4dataset/annotation/scene.json diff --git a/tests/sample/annotation/sensor.json b/tests/sample/t4dataset/annotation/sensor.json similarity index 100% rename from tests/sample/annotation/sensor.json rename to tests/sample/t4dataset/annotation/sensor.json diff --git a/tests/sample/annotation/surface_ann.json b/tests/sample/t4dataset/annotation/surface_ann.json similarity index 100% rename from tests/sample/annotation/surface_ann.json rename to tests/sample/t4dataset/annotation/surface_ann.json diff --git a/tests/sample/annotation/vehicle_state.json b/tests/sample/t4dataset/annotation/vehicle_state.json similarity index 100% rename from tests/sample/annotation/vehicle_state.json rename to tests/sample/t4dataset/annotation/vehicle_state.json diff --git a/tests/sample/annotation/visibility.json b/tests/sample/t4dataset/annotation/visibility.json similarity index 100% rename from tests/sample/annotation/visibility.json rename to tests/sample/t4dataset/annotation/visibility.json diff --git a/tests/sample/data/CAM_BACK/001.jpg b/tests/sample/t4dataset/data/CAM_BACK/001.jpg similarity index 100% rename from tests/sample/data/CAM_BACK/001.jpg rename to tests/sample/t4dataset/data/CAM_BACK/001.jpg diff --git a/tests/sample/data/CAM_BACK/002.jpg b/tests/sample/t4dataset/data/CAM_BACK/002.jpg similarity index 100% rename from tests/sample/data/CAM_BACK/002.jpg rename to tests/sample/t4dataset/data/CAM_BACK/002.jpg diff --git a/tests/sample/data/CAM_BACK/003.jpg b/tests/sample/t4dataset/data/CAM_BACK/003.jpg similarity index 100% rename from tests/sample/data/CAM_BACK/003.jpg rename to tests/sample/t4dataset/data/CAM_BACK/003.jpg diff --git a/tests/sample/data/CAM_FRONT/001.jpg b/tests/sample/t4dataset/data/CAM_FRONT/001.jpg similarity index 100% rename from tests/sample/data/CAM_FRONT/001.jpg rename to tests/sample/t4dataset/data/CAM_FRONT/001.jpg diff --git a/tests/sample/data/CAM_FRONT/002.jpg b/tests/sample/t4dataset/data/CAM_FRONT/002.jpg similarity index 100% rename from tests/sample/data/CAM_FRONT/002.jpg rename to tests/sample/t4dataset/data/CAM_FRONT/002.jpg diff --git a/tests/sample/data/CAM_FRONT/003.jpg b/tests/sample/t4dataset/data/CAM_FRONT/003.jpg similarity index 100% rename from tests/sample/data/CAM_FRONT/003.jpg rename to tests/sample/t4dataset/data/CAM_FRONT/003.jpg diff --git a/tests/sample/data/LIDAR_TOP/001.pcd.bin b/tests/sample/t4dataset/data/LIDAR_TOP/001.pcd.bin similarity index 100% rename from tests/sample/data/LIDAR_TOP/001.pcd.bin rename to tests/sample/t4dataset/data/LIDAR_TOP/001.pcd.bin diff --git a/tests/sample/data/LIDAR_TOP/002.pcd.bin b/tests/sample/t4dataset/data/LIDAR_TOP/002.pcd.bin similarity index 100% rename from tests/sample/data/LIDAR_TOP/002.pcd.bin rename to tests/sample/t4dataset/data/LIDAR_TOP/002.pcd.bin diff --git a/tests/sample/data/LIDAR_TOP/003.pcd.bin b/tests/sample/t4dataset/data/LIDAR_TOP/003.pcd.bin similarity index 100% rename from tests/sample/data/LIDAR_TOP/003.pcd.bin rename to tests/sample/t4dataset/data/LIDAR_TOP/003.pcd.bin diff --git a/tests/sample/map/lanelet2_map.osm b/tests/sample/t4dataset/map/lanelet2_map.osm similarity index 100% rename from tests/sample/map/lanelet2_map.osm rename to tests/sample/t4dataset/map/lanelet2_map.osm diff --git a/tests/sample/status.json b/tests/sample/t4dataset/status.json similarity index 100% rename from tests/sample/status.json rename to tests/sample/t4dataset/status.json diff --git a/tests/test_tier4.py b/tests/test_tier4.py index 16e4cc3..b6808b9 100644 --- a/tests/test_tier4.py +++ b/tests/test_tier4.py @@ -14,8 +14,8 @@ @pytest.fixture(scope="session") -def sample_data_path() -> Path: - return Path(__file__).parent / "sample" +def sample_dataset_path() -> Path: + return Path(__file__).parent / "sample/t4dataset" class TestDBMetadata: @@ -26,26 +26,26 @@ def test_db_metadata_creation(self): metadata = DBMetadata( data_root="/path/to/data", dataset_id="test_dataset", - version="v1.0", + version="1", ) assert metadata.data_root == "/path/to/data" assert metadata.dataset_id == "test_dataset" - assert metadata.version == "v1.0" + assert metadata.version == "1" class TestLoadMetadata: """Test cases for load_metadata function.""" - def test_load_metadata_with_status_file(self, sample_data_path): + def test_load_metadata_with_status_file(self, sample_dataset_path): """Test loading metadata when status.json exists.""" - if not sample_data_path.exists(): + if not sample_dataset_path.exists(): pytest.skip("Sample dataset not available") - metadata = load_metadata(sample_data_path.as_posix()) + metadata = load_metadata(sample_dataset_path.as_posix()) - assert metadata.data_root == sample_data_path.as_posix() - assert metadata.dataset_id == "sample" + assert metadata.data_root == sample_dataset_path.as_posix() + assert metadata.dataset_id == "t4dataset" assert metadata.version is None def test_load_metadata_without_status_file(self, tmp_path): @@ -70,13 +70,13 @@ def test_load_metadata_with_specific_revision(self, tmp_path): class TestLoadTable: """Test cases for load_table function.""" - def test_load_table_success(self, sample_data_path): + def test_load_table_success(self, sample_dataset_path): """Test successful table loading.""" - if not sample_data_path.exists(): + if not sample_dataset_path.exists(): pytest.skip("Sample dataset not available") # Create a dummy annotation file - annotation_dir = sample_data_path.joinpath("annotation") + annotation_dir = sample_dataset_path.joinpath("annotation") result = load_table(annotation_dir.as_posix(), SchemaName.ATTRIBUTE) @@ -109,10 +109,10 @@ class TestTier4: @pytest.fixture(scope="class") def sample_t4(self): """Create a Tier4 instance using the real sample dataset.""" - sample_data_path = Path(__file__).parent / "sample" - if not sample_data_path.exists(): + sample_dataset_path = Path(__file__).parent / "sample/t4dataset" + if not sample_dataset_path.exists(): pytest.skip("Sample dataset not available") - return Tier4(sample_data_path.as_posix(), verbose=False) + return Tier4(sample_dataset_path.as_posix(), verbose=False) def test_dataset_structure_validation(self, sample_t4): """Validate the complete structure of the sample dataset.""" diff --git a/tests/viewer/test_viewer.py b/tests/viewer/test_viewer.py index 0fd0f72..1ad8494 100644 --- a/tests/viewer/test_viewer.py +++ b/tests/viewer/test_viewer.py @@ -135,7 +135,6 @@ def test_render_calibration(dummy_viewer, dummy_camera_calibration) -> None: dummy_viewer.render_calibration(sensor, calibration) -def test_render_map(dummy_viewer) -> None: +def test_render_map(dummy_viewer, dummy_lanelet_path) -> None: """Test rendering map with `RerunViewer`.""" - lanelet_path = "tests/sample/map/lanelet2_map.osm" - dummy_viewer.render_map(lanelet_path) + dummy_viewer.render_map(dummy_lanelet_path) From 747daa07cae63afe6c6e67ab8b706ec07ecb4fb5 Mon Sep 17 00:00:00 2001 From: ktro2828 Date: Tue, 2 Sep 2025 15:15:49 +0900 Subject: [PATCH 2/2] ci: not to spawn rerun viewer on CI device Signed-off-by: ktro2828 --- .github/workflows/build-and-test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index b0ca3be..f640895 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -49,9 +49,9 @@ jobs: - name: Run CLIs if: ${{ steps.is-changed.outputs.changes == 'true'}} run: | - uv run t4viz scene ./tests/sample/t4dataset - uv run t4viz instance ./tests/sample/t4dataset 90f0c98d1a040d5360847f576c5528f8 - uv run t4viz pointcloud ./tests/sample/t4dataset + uv run t4viz scene ./tests/sample/t4dataset -o ./output + uv run t4viz instance ./tests/sample/t4dataset 90f0c98d1a040d5360847f576c5528f8 -o ./output + uv run t4viz pointcloud ./tests/sample/t4dataset -o ./output uv run t4sanity ./tests/sample -iw - name: Get test coverage