omegaconf
omegaconf copied to clipboard
[Question] Why hide dictconfig debugging content?
https://github.com/omry/omegaconf/blob/32e82d3d5ff2eebb7c55b1ba36ec084723f9f685/omegaconf/dictconfig.py#L320-L324
What is the reason for explicitly hiding information about the dictconfig while debugging?
DictConfig does not normally expose the internal representation during debugging because it's not as useful as seeing the user level content.
Why are you asking?
My expectation would be that print(DictConfig())
would show the user-level content, not dir(DictConfig())
.
I was asking because I was inspecting my DictConfig
during debugging to find out what kind of methods it supports; for an analogy, dir({})
also returns all methods supported by a dict
.
>>> dir({2:3})
['__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
>>> print({2:3})
{2: 3}
>>> dir(DictConfig({2:3}))
[2]
>>> print(DictConfig({2:3}))
{2: 3}
I believe the debugger is using _dir_
to list the object fields as well and not overriding dir would result in fields that are not meant to be user visible exposed while debugging.
Since OmegaConf is now using a debugger plugin, this may or may not still be required.