Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python 3.11 dataclass field default_factory defaults #2746

Merged

Conversation

ringohoffman
Copy link
Contributor

Following the Training your first model docs using Python 3.11:

$ ns-train nerfacto --data data/nerfstudio/poster
Traceback (most recent call last):
  File "/home/matthew/.conda/envs/nerfstudio311/bin/ns-train", line 5, in <module>
    from nerfstudio.scripts.train import entrypoint
  File "/home/matthew/Repositories/nerfstudio/nerfstudio/scripts/train.py", line 62, in <module>
    from nerfstudio.configs.method_configs import AnnotatedBaseConfigUnion
  File "/home/matthew/Repositories/nerfstudio/nerfstudio/configs/method_configs.py", line 28, in <module>
    from nerfstudio.configs.external_methods import get_external_methods
  File "/home/matthew/Repositories/nerfstudio/nerfstudio/configs/external_methods.py", line 24, in <module>
    from nerfstudio.engine.trainer import TrainerConfig
  File "/home/matthew/Repositories/nerfstudio/nerfstudio/engine/trainer.py", line 30, in <module>
    from nerfstudio.configs.experiment_config import ExperimentConfig
  File "/home/matthew/Repositories/nerfstudio/nerfstudio/configs/experiment_config.py", line 35, in <module>
    from nerfstudio.pipelines.base_pipeline import VanillaPipelineConfig
  File "/home/matthew/Repositories/nerfstudio/nerfstudio/pipelines/base_pipeline.py", line 42, in <module>
    from nerfstudio.data.datamanagers.full_images_datamanager import FullImageDatamanager
  File "/home/matthew/Repositories/nerfstudio/nerfstudio/data/datamanagers/full_images_datamanager.py", line 47, in <module>
    @dataclass
     ^^^^^^^^^
  File "/home/matthew/.conda/envs/nerfstudio311/lib/python3.11/dataclasses.py", line 1230, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/home/matthew/.conda/envs/nerfstudio311/lib/python3.11/dataclasses.py", line 1220, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matthew/.conda/envs/nerfstudio311/lib/python3.11/dataclasses.py", line 958, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/matthew/.conda/envs/nerfstudio311/lib/python3.11/dataclasses.py", line 815, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'nerfstudio.data.dataparsers.nerfstudio_dataparser.NerfstudioDataParserConfig'> for field dataparser is not allowed: use default_factory

It looks like not all of the mutable default values were set using default_factory, so I have updated them here.

With these changes, I can successfully run the above command using Python 3.11.

Copy link
Collaborator

@brentyi brentyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!!

@brentyi brentyi merged commit e7e713e into nerfstudio-project:main Jan 11, 2024
4 checks passed
@ringohoffman ringohoffman deleted the fix-3.11-default_factory-defaults branch January 11, 2024 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants