-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Added test_set_empty_params
#6484
Conversation
dvc/utils/serialize/_yaml.py
Outdated
@@ -50,6 +51,8 @@ def _get_yaml(): | |||
# tell Dumper to represent OrderedDict as normal dict | |||
yaml_repr_cls = yaml.Representer | |||
yaml_repr_cls.add_representer(OrderedDict, yaml_repr_cls.represent_dict) | |||
yaml_repr_cls.add_representer(benedict, yaml_repr_cls.represent_dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
benedict should never escape when we merge params from --set-params
. This may result in loss of comments.
A fix might be to merge the params in the file recursively from the --set-params
benedict dictionary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I'm fully understanding, what do you mean by escape
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of #6423, I'd like not to use or import benedict elsewhere than the following location, until it is resolved:
Line 83 in 73811f6
def merge_params(src: Dict, to_update: Dict) -> Dict: |
So, the merge_params
should not return any benedict
object, it should return the data of same type as src
, which is usually dict
/CommentedMap
(which preserves comments, coming from ruamel.yaml
).
EDIT: updates on src
should happen in-place, as required by modify_data
contextmanager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed that and replaced with just a regression test currently checking that a exception is being raised. I guess that if we go with #6423 (comment) we should make that test pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
benedict
representer to yaml
test_set_empty_params
Fixes iterative#6476, fixes iterative#6423 and closes iterative#6484.
Sorry for the late review. I have incorporated this test in #6706 (comment), as it gets automatically fixed after updating benedict to the latest version. This bug happened because we were handling an empty dictionary in a different way because of a bug in benedict which we don't need to handle now at all. |
β I have followed the Contributing to DVC checklist.
π If this PR requires documentation updates, I have created a separate PR (or issue, at least) in dvc.org and linked it here.