You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "damccorm (via GitHub)" <gi...@apache.org> on 2025/03/05 16:29:11 UTC
[PR] Correctly parse labels if they are passed as a single string instead of a list [beam]
damccorm opened a new pull request, #34183:
URL: https://github.com/apache/beam/pull/34183
Right now, if you submit a job like:
```
options = PipelineOptions()
options.view_as(StandardOptions).runner = "DataflowRunner"
<other options>
options.view_as(GoogleCloudOptions).labels = {'env': 'bluecore-qa-extensibility', 'team': 'cdp-vertical'}
with beam.Pipeline(options=options) as p:
<do stuff>
```
The job does not correctly recognize the labels. We could validate and fail because labels is expected to be a list, but that might break existing (mostly working) pipelines. This is an in between where we can still do a best effort to correctly identify/use the user's labels.
------------------------
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] Correctly parse labels if they are passed as a single string instead of a list [beam]
Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm merged PR #34183:
URL: https://github.com/apache/beam/pull/34183
--
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] Correctly parse labels if they are passed as a single string instead of a list [beam]
Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm commented on PR #34183:
URL: https://github.com/apache/beam/pull/34183#issuecomment-2701712041
R: @liferoad
--
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] Correctly parse labels if they are passed as a single string instead of a list [beam]
Posted by "liferoad (via GitHub)" <gi...@apache.org>.
liferoad commented on code in PR #34183:
URL: https://github.com/apache/beam/pull/34183#discussion_r1981901879
##########
sdks/python/apache_beam/runners/dataflow/internal/apiclient.py:
##########
@@ -447,6 +447,8 @@ def __init__(self, options, proto_pipeline):
if self.google_cloud_options.labels:
self.proto.labels = dataflow.Job.LabelsValue()
labels = self.google_cloud_options.labels
+ if isinstance(labels, str):
+ labels = [labels]
Review Comment:
do you mean `options.view_as(GoogleCloudOptions).labels = {'env': 'bluecore-qa-extensibility', 'team': 'cdp-vertical'}` is interpreted as a string although it is a Python dict?
--
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] Correctly parse labels if they are passed as a single string instead of a list [beam]
Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm commented on code in PR #34183:
URL: https://github.com/apache/beam/pull/34183#discussion_r1981913875
##########
sdks/python/apache_beam/runners/dataflow/internal/apiclient.py:
##########
@@ -447,6 +447,8 @@ def __init__(self, options, proto_pipeline):
if self.google_cloud_options.labels:
self.proto.labels = dataflow.Job.LabelsValue()
labels = self.google_cloud_options.labels
+ if isinstance(labels, str):
+ labels = [labels]
Review Comment:
Whoops, meant to make this a draft until I full tested it. But you're right, this won't fully work yet. I think I'll also want something like:
```
if not isinstance(labels, Iterable):
labels = [str(labels)]
```
But I'll fix/test this with the string and dict cases
--
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] Correctly parse labels if they are passed as a single string instead of a list [beam]
Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm commented on code in PR #34183:
URL: https://github.com/apache/beam/pull/34183#discussion_r1981913875
##########
sdks/python/apache_beam/runners/dataflow/internal/apiclient.py:
##########
@@ -447,6 +447,8 @@ def __init__(self, options, proto_pipeline):
if self.google_cloud_options.labels:
self.proto.labels = dataflow.Job.LabelsValue()
labels = self.google_cloud_options.labels
+ if isinstance(labels, str):
+ labels = [labels]
Review Comment:
Whoops, meant to make this a draft until I full tested it. But you're right, this won't fully work yet. I think this should be more like:
```
if not isinstance(labels, Iterable):
labels = [str(labels)]
```
But I'll fix/test this
--
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] Correctly parse labels if they are passed as a single string instead of a list [beam]
Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm commented on code in PR #34183:
URL: https://github.com/apache/beam/pull/34183#discussion_r1981926121
##########
sdks/python/apache_beam/runners/dataflow/internal/apiclient.py:
##########
@@ -447,6 +447,8 @@ def __init__(self, options, proto_pipeline):
if self.google_cloud_options.labels:
self.proto.labels = dataflow.Job.LabelsValue()
labels = self.google_cloud_options.labels
+ if isinstance(labels, str):
+ labels = [labels]
Review Comment:
This should now handle both cases, and I added some representative test cases, PTAL
--
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] Correctly parse labels if they are passed as a single string instead of a list [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #34183:
URL: https://github.com/apache/beam/pull/34183#issuecomment-2701714441
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment `assign set of reviewers`
--
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