Skip to content

Set user agent when downloading jars with local_jar - #36342

Merged
Abacn merged 3 commits into
apache:masterfrom
Abacn:local-jar-agent
Oct 2, 2025
Merged

Set user agent when downloading jars with local_jar#36342
Abacn merged 3 commits into
apache:masterfrom
Abacn:local-jar-agent

Conversation

@Abacn

@Abacn Abacn commented Sep 30, 2025

Copy link
Copy Markdown
Contributor

Related: #36338

Please add a meaningful description for your change here


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.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@Abacn
Abacn force-pushed the local-jar-agent branch 2 times, most recently from 1be2aea to 4e0de77 Compare September 30, 2025 21:41
@Abacn

Abacn commented Sep 30, 2025

Copy link
Copy Markdown
Contributor Author

It's tricky to enter e2e tests (from pipeline option to check user agent in request) because the code path is excluded from dev Beam:

needed to comment out these lines to make test script pass over this check. Tested that --user_agent pipeline option is honored when expanding a pipeline contains kafkaio. For this PR, added a check on request for default user agent (Apache Beam Python SDK/...) in test

@Abacn
Abacn marked this pull request as ready for review September 30, 2025 22:31
@github-actions

github-actions Bot commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

'sdk worker container image.'))
parser.add_argument(
'--user_agent',
default=None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we set new default e.g. "Apache Beam" ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree - from conversations with the sonatype folks, it sounds like having a default would be very helpful

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The default is set here: https://github.com/apache/beam/pull/36342/files#diff-fd140abcfcbb9b91db28c94a0458d02b4eb21f7f61db4935bf501464b27e1cfeR291 if user not setting this value the user agent is set to "Apache Beam Python SDK/2.xx.0"

The problem of default pipeline options is that Java already has a --userAgent option defaults to "Apache Beam Java SDK/2.xx.0". This change is essentially port the option to Python. However Java side default is handled by a DefaultFactory class, but if I set a non-empty str as default in Python, I afraid am it could pass to Java side when running portable pipelines / xlang pipelines, or other unintended result

@github-actions

github-actions Bot commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @liferoad 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).

@liferoad

liferoad commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a --user_agent option to specify a user agent when downloading JAR files. The changes are well-implemented, propagating the new option from the pipeline configuration down to the network request level. A default user agent is also thoughtfully included. I've found a minor but important typo in one of the files that needs to be corrected.

Comment thread sdks/python/apache_beam/runners/portability/spark_uber_jar_job_server.py Outdated
Comment thread sdks/python/apache_beam/runners/portability/spark_uber_jar_job_server.py Outdated
@Abacn

Abacn commented Oct 1, 2025

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for setting a user agent when downloading JAR files. The changes correctly plumb the user_agent option from pipeline options down to the urlopen call. I have two main points of feedback regarding potential issues with object state and caching that could lead to unexpected behavior. Other than these points, the changes look good and effectively implement the desired feature.

Comment thread sdks/python/apache_beam/utils/transform_service_launcher.py
Comment thread sdks/python/apache_beam/transforms/external.py
@Abacn

Abacn commented Oct 2, 2025

Copy link
Copy Markdown
Contributor Author

MilvusException in Python3.12 ML PreCommit, not related to this change

@Abacn
Abacn merged commit 6b9d534 into apache:master Oct 2, 2025
102 of 105 checks passed
@Abacn
Abacn deleted the local-jar-agent branch October 2, 2025 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants