Skip to content

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