omegaconf icon indicating copy to clipboard operation
omegaconf copied to clipboard

[Question] Why hide dictconfig debugging content?

Open robogast opened this issue 3 years ago • 3 comments

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?

robogast avatar Oct 14 '21 11:10 robogast

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?

omry avatar Oct 14 '21 19:10 omry

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}

robogast avatar Oct 15 '21 13:10 robogast

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.

omry avatar Oct 15 '21 20:10 omry