Skip to content
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

[bug fix] Flow decorator click option names fix #1775

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

valayDave
Copy link
Collaborator

  • When we expose flow decorator options with a - in the name, the code crashes at setting deco_flow_init_options with a KeyError on deco_options. The deco_options as passed down from Click which converts any option with - to _.
  • translating the - to _ ensures the option can match the value in deco_options and doesn't result in KeyError. This is only the case when options contain -
  • Already present flow decorators will have no issues anyways since this only effects flow deco options that have a - in the name (which currently none of them do).
  • This doesn't handle the case where option names have _. But opens up creation of options with -'s.

@@ -518,7 +518,7 @@ def _init_flow_decorators(
else:
# Each "non-multiple" flow decorator is only allowed to have one set of options
deco_flow_init_options = {
option: deco_options[option] for option in deco.options
option: deco_options[option.replace("-", "_")] for option in deco.options
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • When we expose flow decorator options with a - in the name, the code crashes at setting deco_flow_init_options with a KeyError on deco_options. The deco_options as passed down from Click which converts any option with - to _.
  • translating the - to _ ensures the option can match the value in deco_options and doesn't result in KeyError. This is only the case when options contain -
  • Already present flow decorators will have no issues anyways since this only effects flow deco options that have a - in the name (which currently none of them do).
  • This doesn't handle the case where option names have _. But opens up creation of options with -'s.

- When we expose flow decorator options with a `-` in the name, the code crashes at setting `deco_flow_init_options` with a KeyError on `deco_options`. The `deco_options` as passed down from Click which converts any `option` with `-` to `_`.
- translating the `-` to `_` ensures the `option` can match the value in `deco_options` and doesn't result in KeyError. This is only the case **when options contain `-`**
- Already present flow decorators will have no issues anyways since this only effects flow deco options that have a `-` in the name (which currently none of them do).
- This doesn't handle the case where option names have `_`. But opens up creation of options with `-`'s.
@valayDave valayDave force-pushed the valay/fix-deco-attr branch from b964221 to 0229de8 Compare March 27, 2024 03:51
valayDave added a commit to valayDave/metaflow that referenced this pull request Mar 27, 2024
Linked to upstream : [Netflix#1775]

- When we expose flow decorator options with a `-` in the name, the code crashes at setting `deco_flow_init_options` with a KeyError on `deco_options`. The `deco_options` as passed down from Click which converts any `option` with `-` to `_`.
- translating the `-` to `_` ensures the `option` can match the value in `deco_options` and doesn't result in KeyError. This is only the case **when options contain `-`**
- Already present flow decorators will have no issues anyways since this only effects flow deco options that have a `-` in the name (which currently none of them do).
- This doesn't handle the case where option names have `_`. But opens up creation of options with `-`'s.
@romain-intel romain-intel merged commit 8f576e6 into Netflix:master Apr 5, 2024
32 of 34 checks passed
@valayDave valayDave deleted the valay/fix-deco-attr branch April 18, 2024 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants