-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
parlai/core/params.py
Outdated
# handle the single dash stuff. See _handle_single_dash_addarg for info | ||
actions = set() | ||
for action in self._actions: | ||
actions = actions | set(action.option_strings) |
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.
Why not just add(action)
?
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.
I could use set.update(action.option_strings)
but not set.add
. option_strings is a list
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.
Quick timer check shows that's much faster, so I'll update
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.
Ok, I didn't know it is list. It makes sense like this then. Thanks for clarifying.
return args | ||
|
||
out_long = [] | ||
out_short = [] |
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.
nit: why can't they both use the same list? You returned their aggregated version only anyway.
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.
bc i'm being cute and swapping the ordering
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.
we tend to define options like add_argument('-hs', '--hiddensize')
but we need it to add_argument('--hiddensize', '--hs')
or otherwise it will try to store the value to opt['hs']
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.
Oh, I see. That makes sense.
Patch description
ParlAI likes to use short options like
-hs 1024
. Since Python 3.8, this has been broken, and gets parsed as-h s 1024
.Although we've patched a few places previously (example), there continue to be little bits and places left. This patch should fix all of them by changing everything to double dashes under the hood.
Testing steps
CI, manual testing.