-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Pass options in DaskOptions inheritance hierarchy only for Dask runner #37101
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -486,11 +486,12 @@ def get_all_options( | |
| drop_default=False, | ||
| add_extra_args_fn: Optional[Callable[[_BeamArgumentParser], None]] = None, | ||
| retain_unknown_options=False, | ||
| display_warnings=False) -> Dict[str, Any]: | ||
| display_warnings=False, | ||
| hierarchy_only=False, | ||
| ) -> Dict[str, Any]: | ||
| """Returns a dictionary of all defined arguments. | ||
|
|
||
| Returns a dictionary of all defined arguments (arguments that are defined in | ||
| any subclass of PipelineOptions) into a dictionary. | ||
| Returns a dictionary of all defined arguments into a dictionary. | ||
|
|
||
| Args: | ||
| drop_default: If set to true, options that are equal to their default | ||
|
|
@@ -500,6 +501,9 @@ def get_all_options( | |
| retain_unknown_options: If set to true, options not recognized by any | ||
| known pipeline options class will still be included in the result. If | ||
| set to false, they will be discarded. | ||
| hierarchy_only: If set to true, only returns options defined in this class | ||
| and its super classes only. Otherwise, arguments that are defined in | ||
| any subclass of PipelineOptions are returned (default). | ||
|
|
||
| Returns: | ||
| Dictionary of all args and values. | ||
|
|
@@ -510,8 +514,13 @@ def get_all_options( | |
| # instance of each subclass to avoid conflicts. | ||
| subset = {} | ||
| parser = _BeamArgumentParser(allow_abbrev=False) | ||
| for cls in PipelineOptions.__subclasses__(): | ||
| subset.setdefault(str(cls), cls) | ||
| if not hierarchy_only: | ||
|
||
| for cls in PipelineOptions.__subclasses__(): | ||
| subset.setdefault(str(cls), cls) | ||
| else: | ||
| for cls in self.__class__.__mro__: | ||
| if issubclass(cls, PipelineOptions): | ||
| subset.setdefault(str(cls), cls) | ||
| for cls in subset.values(): | ||
| cls._add_argparse_args(parser) # pylint: disable=protected-access | ||
| if add_extra_args_fn: | ||
|
|
@@ -562,7 +571,7 @@ def add_new_arg(arg, **kwargs): | |
| continue | ||
| parsed_args, _ = parser.parse_known_args(self._flags) | ||
| else: | ||
| if unknown_args: | ||
| if unknown_args and not hierarchy_only: | ||
| _LOGGER.warning("Discarding unparseable args: %s", unknown_args) | ||
| parsed_args = known_args | ||
| result = vars(parsed_args) | ||
|
|
@@ -580,7 +589,7 @@ def add_new_arg(arg, **kwargs): | |
| if overrides: | ||
| if retain_unknown_options: | ||
| result.update(overrides) | ||
| else: | ||
| elif not hierarchy_only: | ||
| _LOGGER.warning("Discarding invalid overrides: %s", overrides) | ||
|
|
||
| return result | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we have use-cases for is returning options from superclasses? would it be sufficient to return only options defined in the current class?
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.
Yeah for current one (DaskOptions) it is sufficient. Simplified.