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

[params] Support options depending on options in parse_kwargs. #3900

Merged
merged 3 commits into from
Aug 5, 2021

Conversation

stephenroller
Copy link
Contributor

Patch description
@ankitade reported an issue where systems using parse_kwargs (such as internal customers and the Colab notebooks) could not correctly use Mutator options. Debugging, it appears this derives from not having enough repeated iterations of add_cmdline_args being called with options that depend on other options.

Previously: Parse 'task=' and call the Task.add_cmdline_args. However, since --mutators hasn't been added yet, partial_opt doesn't contain any mutators and we don't load these in.

After: We repeatedly parse kwargs until there are remaining unparsed arguments, or we do not see any improvements (fixed point)

Testing steps
New CI examples that previously would not pass.

Comment on lines +1207 to +1209
unparsed_args = set(kwargs.keys())
while unparsed_args:
string_args = []
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 lines are the real change (the rest is just indentation)

Comment on lines +1252 to +1254
if kwname not in kwname_to_action:
new_unparsed_args.add(kwname)
continue
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are new

Comment on lines +1271 to +1280
if new_unparsed_args == unparsed_args:
# if we have converged to a fixed point with no improvements, we
# truly found some unreachable args
raise KeyError(
f'Failed to parse one or more kwargs: {", ".join(new_unparsed_args)}'
)
else:
raise TypeError(f"Don't know what to do with {action}")
# We've seen some improvements on the number of unparsed args,
# iterate again
unparsed_args = new_unparsed_args
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are new

@stephenroller stephenroller merged commit 6ca525c into master Aug 5, 2021
@stephenroller stephenroller deleted the multihop_kwargs branch August 5, 2021 16:45
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.

3 participants