You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "liferoad (via GitHub)" <gi...@apache.org> on 2025/07/13 18:15:44 UTC
[PR] feat(options): add support for comma-separated options [beam]
liferoad opened a new pull request, #35580:
URL: https://github.com/apache/beam/pull/35580
Implement _CommaSeparatedListAction to handle comma-separated values for experiments and dataflow_service_options, matching Java SDK behavior. This allows more flexible input formats while maintaining backward compatibility.
Fixes #35563
------------------------
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
- [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(options): add support for comma-separated options [beam]
Posted by "liferoad (via GitHub)" <gi...@apache.org>.
liferoad commented on code in PR #35580:
URL: https://github.com/apache/beam/pull/35580#discussion_r2205016418
##########
sdks/python/apache_beam/options/pipeline_options.py:
##########
@@ -220,6 +220,70 @@ def __call__(self, parser, namespace, values, option_string=None):
% _GcsCustomAuditEntriesAction.MAX_ENTRIES)
+class _CommaSeparatedListAction(argparse.Action):
+ """
+ Argparse Action that splits comma-separated values and appends them to
+ a list. This allows options like --experiments=abc,def to be treated
+ as separate experiments 'abc' and 'def', similar to how Java SDK handles
+ them.
+
+ For key=value experiments, only splits at commas that are not part of the
+ value. For example: 'abc,def,master_key=k1=v1,k2=v2' becomes
+ ['abc', 'def', 'master_key=k1=v1,k2=v2']
+ """
+ def __call__(self, parser, namespace, values, option_string=None):
+ if not hasattr(namespace, self.dest) or getattr(namespace,
+ self.dest) is None:
+ setattr(namespace, self.dest, [])
+
+ # Split comma-separated values and extend the list
+ if isinstance(values, str):
+ # Smart splitting: only split at commas that are not part of
+ # key=value pairs
+ split_values = self._smart_split(values)
+ getattr(namespace, self.dest).extend(split_values)
+ else:
+ # If values is not a string, just append it
+ getattr(namespace, self.dest).append(values)
+
+ def _smart_split(self, values):
Review Comment:
This will break the current behaviour tested by https://github.com/apache/beam/blob/2b289f2804d76e75e857928a058d2d7c33f85de3/sdks/python/apache_beam/options/pipeline_options_test.py#L636.
This is why `master_key=k1=v1,k2=v2` should be treated as one key not simply split by comma.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(options): add support for comma-separated options [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #35580:
URL: https://github.com/apache/beam/pull/35580#issuecomment-3067288743
Assigning reviewers:
R: @shunping for label python.
Note: If you would like to opt out of this review, comment `assign to next reviewer`.
Available commands:
- `stop reviewer notifications` - opt out of the automated review tooling
- `remind me after tests pass` - tag the comment author after tests pass
- `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
The PR bot will only process comments in the main thread (not review comments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(options): add support for comma-separated options [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on code in PR #35580:
URL: https://github.com/apache/beam/pull/35580#discussion_r2204829999
##########
sdks/python/apache_beam/options/pipeline_options.py:
##########
@@ -220,6 +220,70 @@ def __call__(self, parser, namespace, values, option_string=None):
% _GcsCustomAuditEntriesAction.MAX_ENTRIES)
+class _CommaSeparatedListAction(argparse.Action):
+ """
+ Argparse Action that splits comma-separated values and appends them to
+ a list. This allows options like --experiments=abc,def to be treated
+ as separate experiments 'abc' and 'def', similar to how Java SDK handles
+ them.
+
+ For key=value experiments, only splits at commas that are not part of the
+ value. For example: 'abc,def,master_key=k1=v1,k2=v2' becomes
+ ['abc', 'def', 'master_key=k1=v1,k2=v2']
+ """
+ def __call__(self, parser, namespace, values, option_string=None):
+ if not hasattr(namespace, self.dest) or getattr(namespace,
+ self.dest) is None:
+ setattr(namespace, self.dest, [])
+
+ # Split comma-separated values and extend the list
+ if isinstance(values, str):
+ # Smart splitting: only split at commas that are not part of
+ # key=value pairs
+ split_values = self._smart_split(values)
+ getattr(namespace, self.dest).extend(split_values)
+ else:
+ # If values is not a string, just append it
+ getattr(namespace, self.dest).append(values)
+
+ def _smart_split(self, values):
Review Comment:
We can just separate comma, and this is how java currently does. The valued experiments / DataflowPipelineOptions do not have further keys.
The current comment about "smart" split does not make sense, `master_key=k1=v1,k2=v2` is ambiguious by nature, saying it can also refer to two expeiments named "master_key" and "k2"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(options): add support for comma-separated options [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on code in PR #35580:
URL: https://github.com/apache/beam/pull/35580#discussion_r2205290402
##########
sdks/python/apache_beam/options/pipeline_options.py:
##########
@@ -220,6 +220,70 @@ def __call__(self, parser, namespace, values, option_string=None):
% _GcsCustomAuditEntriesAction.MAX_ENTRIES)
+class _CommaSeparatedListAction(argparse.Action):
+ """
+ Argparse Action that splits comma-separated values and appends them to
+ a list. This allows options like --experiments=abc,def to be treated
+ as separate experiments 'abc' and 'def', similar to how Java SDK handles
+ them.
+
+ For key=value experiments, only splits at commas that are not part of the
+ value. For example: 'abc,def,master_key=k1=v1,k2=v2' becomes
+ ['abc', 'def', 'master_key=k1=v1,k2=v2']
+ """
+ def __call__(self, parser, namespace, values, option_string=None):
+ if not hasattr(namespace, self.dest) or getattr(namespace,
+ self.dest) is None:
+ setattr(namespace, self.dest, [])
+
+ # Split comma-separated values and extend the list
+ if isinstance(values, str):
+ # Smart splitting: only split at commas that are not part of
+ # key=value pairs
+ split_values = self._smart_split(values)
+ getattr(namespace, self.dest).extend(split_values)
+ else:
+ # If values is not a string, just append it
+ getattr(namespace, self.dest).append(values)
+
+ def _smart_split(self, values):
Review Comment:
Thanks, I see, this is tricky. Can we rephrase the comment
> For key=value experiments, only splits at commas that are not part of the
value. For example: 'abc,def,master_key=k1=v1,k2=v2' becomes
['abc', 'def', 'master_key=k1=v1,k2=v2']
to something like
> If there are key=value experiments in a raw argument, the remaining part of the argument are treated as values and won't split further. For example: 'abc,def,master_key=k1=v1,k2=v2' becomes
['abc', 'def', 'master_key=k1=v1,k2=v2'].
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(options): add support for comma-separated options [beam]
Posted by "liferoad (via GitHub)" <gi...@apache.org>.
liferoad merged PR #35580:
URL: https://github.com/apache/beam/pull/35580
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org