From 1dc2ebd9dc1b552b1952f62dab2cedd34308e7bb Mon Sep 17 00:00:00 2001 From: Qizhi Chen Date: Tue, 21 Jan 2025 19:32:35 +0800 Subject: [PATCH] Fix cli bug in high version of tyro (#3567) * limited the tyro version up to 0.9.2 * bump tyro>=0.9.8 * Bump typeguard * Runtime checking with jaxtyping hook instead of typeguard * Fix test for Python >=3.11, caused by missing default_factory --------- Co-authored-by: Brent Yi Co-authored-by: Justin Kerr --- docs/developer_guides/new_methods.md | 4 ++-- pyproject.toml | 5 ++--- tests/plugins/test_registry.py | 10 ++++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/developer_guides/new_methods.md b/docs/developer_guides/new_methods.md index dd1ef31e76..aefd1384ac 100644 --- a/docs/developer_guides/new_methods.md +++ b/docs/developer_guides/new_methods.md @@ -83,7 +83,7 @@ The `NERFSTUDIO_METHOD_CONFIGS` environment variable additionally accepts a func ```python """my_method/my_config.py""" -from dataclasses import dataclass +from dataclasses import dataclass, field from nerfstudio.engine.trainer import TrainerConfig from nerfstudio.plugins.types import MethodSpecification @@ -95,7 +95,7 @@ def MyMethodFunc(): @dataclass class MyMethodClass(MethodSpecification): - config: TrainerConfig = TrainerConfig(...) + config: TrainerConfig = field(default_factory=lambda: TrainerConfig(...)) description: str = "Custom description" ``` diff --git a/pyproject.toml b/pyproject.toml index 2deda4fd36..b7f60f6d9b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ "av>=9.2.0", "comet_ml>=3.33.8", "cryptography>=38", - "tyro>=0.6.6", + "tyro>=0.9.8", "gdown>=4.6.0", "ninja>=1.10", "h5py>=2.9.0", @@ -93,7 +93,6 @@ dev = [ "pre-commit==3.3.2", "pytest==7.1.2", "pytest-xdist==2.5.0", - "typeguard==2.13.3", "ruff>=0.6.1", "sshconf==0.2.5", "pycolmap>=0.3.0", # NOTE: pycolmap==0.3.0 is not available on newer python versions @@ -146,7 +145,7 @@ include = ["nerfstudio*"] "*" = ["*.cu", "*.json", "py.typed", "setup.bash", "setup.zsh"] [tool.pytest.ini_options] -addopts = "-n=4 --typeguard-packages=nerfstudio --disable-warnings" +addopts = "-n=4 --jaxtyping-packages=nerfstudio --disable-warnings" testpaths = [ "tests", ] diff --git a/tests/plugins/test_registry.py b/tests/plugins/test_registry.py index ae704be4c5..cf8855e590 100644 --- a/tests/plugins/test_registry.py +++ b/tests/plugins/test_registry.py @@ -20,10 +20,12 @@ @dataclass class TestConfigClass(MethodSpecification): - config: TrainerConfig = TrainerConfig( - method_name="test-method", - pipeline=VanillaPipelineConfig(), - optimizers={}, + config: TrainerConfig = field( + default_factory=lambda: TrainerConfig( + method_name="test-method", + pipeline=VanillaPipelineConfig(), + optimizers={}, + ) ) description: str = "Test description"