-
Notifications
You must be signed in to change notification settings - Fork 106
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
Shallow copy not working correctly for DictConfig #450
Comments
Hi, this looks identical to the semantics of copy on the standard dict:
You should probably use copy.deepcopy(). |
Closing as I think it's not a bug, let me know if you disagree. |
Oh yes good point, I totally agree that for the nested DictConfigs it is the same behaviour as standard dictionaries. |
Can you create a minimal example where the behavior of the DictConfig deviates from that of the standard config? |
I meant that DictConfig does not behave like dictionaries of the standard python library. Standard dictionaries:
DictConfig:
|
Gotcha. definitely looks like a bug. |
Once this is fixed, we should consider backporting to the 2.0_branch. |
Perfect thanks! |
@odelalleau, @pereman2 can one if you take a look? |
Sure |
@pereman2, can you backport to 2.0? |
This is merged to the 2.0 branch. We will probably wait a bit before releasing 2.0.6 to see if there are any other small bugfixes it should include. |
@louismartin, I am guessing that you also want this in fbcode. Ping me on Workplace to discuss how to get this done (should be easy). |
Describe the bug
It seems that DictConfig objects cannot be copied in python. I am not sure if this is expected behaviour or not.
To Reproduce
Outputs:
Simple fix
A simple fix would be to first cast the object to a dict:
Outputs:
This however only works for first level attributes, nested DictConfigs won't be casted to dict and will therefore be modified inplace.
For instance:
Outputs:
This caused a downstream bug in fairseq: facebookresearch/fairseq#3011
The text was updated successfully, but these errors were encountered: