Skip to content

Enforce binary-only constraints during early requirements cache attempts#38688

Open
shunping wants to merge 4 commits into
apache:masterfrom
shunping:fix-stager
Open

Enforce binary-only constraints during early requirements cache attempts#38688
shunping wants to merge 4 commits into
apache:masterfrom
shunping:fix-stager

Conversation

@shunping
Copy link
Copy Markdown
Collaborator

@shunping shunping commented May 26, 2026

Previously, pip download was executed with preferred platform configurations (e.g., manylinux_2_28_x86_64). However, if no matching binary wheel (.whl) was found, pip would by default fall back to downloading the source distribution (sdist) directly.

We modified the fallback logic here by injecting --only-binary=:all: to enforce downloading only binary wheels in the early attempts. For example, for numpy 2.2.6, we first try downloading the manylinux_2_28_x86_64 wheel. When it fails due to no such wheel, we then try downloading the manylinux2014_x86_64 wheel. If we could not find any wheels for the platforms on the list, we will fallback to source distribution in the end.

This fixed timeout errors in PreCommit Python 3.10 (for MLTest.test_ml_preprocessing_yaml in https://github.com/apache/beam/actions/runs/26420471407/job/77774009271), and PostCommit Python 3.10 (for VertexAIImageEmbeddingsTest.test_image_embedding_pipeline_from_path in https://github.com/apache/beam/actions/runs/26424456835/job/77785233507), because rather than staging and building numpy from source, we only need to download the correct version of wheels, which shortens the expansion service startup time during pytest.

Also related to GoogleCloudPlatform/DataflowTemplates#3533

@shunping shunping marked this pull request as ready for review May 26, 2026 03:39
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the reliability of the Apache Beam Stager by implementing a fallback mechanism for manylinux platform tags. By attempting downloads with progressively more compatible platform tags when the preferred tag fails, the system avoids unnecessary errors during the staging of dependencies that may not have published modern wheels.

Highlights

  • Manylinux Platform Fallbacks: Introduced a list of prioritized manylinux platform tags to allow the Stager to dynamically fall back to older, more compatible standards if modern tags fail during pip downloads.
  • Robust Pip Download Logic: Refactored the pip download process to iterate through fallback platforms, ensuring that cross-platform binary dependencies can be successfully staged even when specific modern wheels are missing from PyPI.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

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

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 fallback mechanism for downloading Python dependencies using pip, iterating through a list of older manylinux platform tags if the preferred modern tag fails. The review feedback highlights that the hardcoded _MANYLINUX_PLATFORMS list only supports _x86_64 architectures, which bypasses the fallback mechanism on ARM64 (aarch64) environments. To resolve this, it is recommended to define base tags and dynamically append the architecture suffix, while filtering out unsupported combinations like manylinux2010 on ARM64.

Comment thread sdks/python/apache_beam/runners/portability/stager.py
Comment thread sdks/python/apache_beam/runners/portability/stager.py
@github-actions
Copy link
Copy Markdown
Contributor

Assigning reviewers:

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

@shunping
Copy link
Copy Markdown
Collaborator Author

shunping commented May 26, 2026

cc: @claudevdm

@github-actions
Copy link
Copy Markdown
Contributor

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

@shunping shunping changed the title Add fallback platforms for stager Enforce binary-only constraints during early requirements cache attempts May 26, 2026
@shunping
Copy link
Copy Markdown
Collaborator Author

cc'ed @derrickaw

@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 63.33333% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.39%. Comparing base (d901481) to head (bb20201).
⚠️ Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
...s/python/apache_beam/runners/portability/stager.py 63.33% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #38688   +/-   ##
=========================================
  Coverage     58.38%   58.39%           
  Complexity    14637    14637           
=========================================
  Files          2725     2725           
  Lines        271438   271498   +60     
  Branches      11884    11884           
=========================================
+ Hits         158490   158539   +49     
- Misses       106801   106812   +11     
  Partials       6147     6147           
Flag Coverage Δ
python 79.87% <63.33%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant