-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[SeeKeR] Opt construction for Python 3.8 #4458
Conversation
projects/seeker/agents/seeker.py
Outdated
@@ -201,7 +201,7 @@ def add_additional_subagent_args(cls, parser: ParlaiParser) -> ParlaiParser: | |||
""" | |||
additional_agent_parser = cls.get_additional_agent_args() | |||
for action in additional_agent_parser._actions: | |||
key = action.option_strings[-1] | |||
key = sorted(action.option_strings, key=lambda x: len(x))[-1] |
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: do you think using max
makes it slightly shorter? You wouldn't need the [-1]
.
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 yeah good point.
edit: we'll still need to index into action.option_strings
so not sure how that would look practically
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.
since we're dealing with strings not numbers
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 don't understand, the behavior shouldn't change between the max or sort here.
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.
Max instead of sorted...
sorry i totally forgot |
Patch description
Fixes issue in #4451
The opt construction for sub-opts for each agent takes the final option string in the parser; for python < 3.8, this would always be the
--
option when a-
was also present. In Python >=3.8, this seems to be non-deterministic.The new logic ensures we get the long option every time.
Testing steps
Tested sample commands from #4451