-
Notifications
You must be signed in to change notification settings - Fork 26.3k
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
parse arguments from dict #4869
parse arguments from dict #4869
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4869 +/- ##
==========================================
+ Coverage 76.55% 76.57% +0.01%
==========================================
Files 128 128
Lines 21502 21510 +8
==========================================
+ Hits 16461 16471 +10
+ Misses 5041 5039 -2
Continue to review full report at Codecov.
|
@@ -152,6 +152,20 @@ def test_with_optional(self): | |||
args = parser.parse_args("--foo 12 --bar 3.14 --baz 42 --ces a b c --des 1 2 3".split()) | |||
self.assertEqual(args, Namespace(foo=12, bar=3.14, baz="42", ces=["a", "b", "c"], des=[1, 2, 3])) | |||
|
|||
def test_parse_dict(self): | |||
parser = HfArgumentParser(BasicExample) |
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.
This is nit-picking, but the unit test would be more realistic if it took more than one dataclass, like ((BasicExample, AnotherExample))
Hi @LysandreJik , what do you think about this ? If it's not really necessary, I will close the PR. Thanks! |
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.
No, I think this is a cool addition, it just got off my radar. Thanks!
* add parse_dict to parse arguments from dict * add unit test for parse_dict
This PR adds parse_dict method to HfArgumentParser to allow parsing arguments from dict
@julien-c
As suggested by you here #4791, I've added a simple unit test to check if the dataclass returned by
parse_dict
is same as manually initialised one.