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

Check off a todo in utils: add 'freeze()' to freeze config. #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JosephCatrambone
Copy link

Adds a three-line method which uses namedtuple to create frozen configs if one wants to avoid footguns. Checks off the 'todo' item in config. Elements of the config are still accessible by name and as dicts.

Example usage:

>>> cfg = CfgNode(a=0, b=0)
>>> cfg.merge_from_args(['--a=2', '--b=3'])
command line overwriting config attribute a with 2
command line overwriting config attribute b with 3
>>> cfg_frozen = cfg.freeze()
>>> cfg_frozen.a
2
>>> a_frozen.a = 3
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[18], line 1
----> 1 cfg_frozen.cfg = 3                                                                                                                                                                                                                        
                                                                                                                       
AttributeError: can't set attribute

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.

1 participant