Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

[SeeKeR] Opt construction for Python 3.8 #4458

Merged
merged 3 commits into from
Mar 30, 2022
Merged

[SeeKeR] Opt construction for Python 3.8 #4458

merged 3 commits into from
Mar 30, 2022

Conversation

klshuster
Copy link
Contributor

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

@@ -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]
Copy link
Contributor

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].

Copy link
Contributor Author

@klshuster klshuster Mar 28, 2022

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

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

@stephenroller stephenroller left a 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...

@klshuster
Copy link
Contributor Author

sorry i totally forgot max could take a key arg

@klshuster klshuster merged commit 42e5773 into main Mar 30, 2022
@klshuster klshuster deleted the seeker_py38 branch March 30, 2022 14:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants