From 4d3bb4dd74f76e6f4cdfeb2b655f3d6020517180 Mon Sep 17 00:00:00 2001 From: MedericFourmy Date: Tue, 31 Oct 2023 05:57:36 -0400 Subject: [PATCH] fix omegaconf parsing issue: Union types syntax | only supported in 3.10 --- .../megapose/inference/types.py | 3 +- tests/test_omega_conf.py | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/test_omega_conf.py diff --git a/happypose/pose_estimators/megapose/inference/types.py b/happypose/pose_estimators/megapose/inference/types.py index 36d74d1b..23c73c10 100644 --- a/happypose/pose_estimators/megapose/inference/types.py +++ b/happypose/pose_estimators/megapose/inference/types.py @@ -17,6 +17,7 @@ from __future__ import annotations # Standard Library +from typing import Union from dataclasses import dataclass # Third Party @@ -93,7 +94,7 @@ class InferenceConfig: n_refiner_iterations: int = 5 n_pose_hypotheses: int = 5 run_depth_refiner: bool = False - depth_refiner: str | None = None # ['icp', 'teaserpp'] + depth_refiner: Union[str, None] = None # ['icp', 'teaserpp'] bsz_objects: int = 16 # How many parallel refiners to run bsz_images: int = 288 # How many images to push through coarse model diff --git a/tests/test_omega_conf.py b/tests/test_omega_conf.py new file mode 100644 index 00000000..444c084c --- /dev/null +++ b/tests/test_omega_conf.py @@ -0,0 +1,29 @@ +from happypose.pose_estimators.megapose.inference.types import InferenceConfig + + +from happypose.pose_estimators.megapose.evaluation.eval_config import ( + BOPEvalConfig, + EvalConfig, + FullEvalConfig, + HardwareConfig, +) +from omegaconf import OmegaConf + + +import unittest + +class TestOmegaConf(unittest.TestCase): + """ + Check if megapose config dataclasses are valid. + """ + + def test_valid_dataclasses(self): + OmegaConf.structured(BOPEvalConfig) + OmegaConf.structured(HardwareConfig) + OmegaConf.structured(InferenceConfig) + OmegaConf.structured(EvalConfig) + OmegaConf.structured(FullEvalConfig) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file