Skip to content

Updates YAML template to set ML dependencies for runtime - #4443

Merged
chamikaramj merged 2 commits into
GoogleCloudPlatform:mainfrom
chamikaramj:ml_runtime_dependencies
Oct 23, 2026
Merged

chamikaramj merged 2 commits into
GoogleCloudPlatform:mainfrom
chamikaramj:ml_runtime_dependencies

Conversation

@chamikaramj

@chamikaramj chamikaramj commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Inspects incoming YAML pipelines for usage of Beam ML transforms 'RunInference' and 'MLTransform'.

If these are detected, sets correct dependencies for the runtime by modifying the default requirements file.

The set of dependencies is customized based on the specific RunInference model handlers and/or specific MLTransform transformations used by the pipeline.

Also adds following Github actions updates updates the existing Python/YAML PR action to include YAML template unit tests.

In a separate PR, I'll add a new Github action to make sure that the dependency versions set here stay consistent with the dependency versions configured in the Beam setup.py file. Not adding it here due to the PR size.

@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 enhances the Beam YAML template by automating the detection and installation of required ML dependencies. By analyzing the pipeline configuration, the template now dynamically determines and sets the appropriate runtime requirements for 'RunInference' and 'MLTransform' components. Additionally, it introduces robust testing and validation mechanisms to ensure that these dependency versions stay synchronized with the core Apache Beam library, reducing the risk of version mismatches in production environments.

Highlights

  • Automatic ML Dependency Management: Implemented logic to inspect YAML pipelines for 'RunInference' and 'MLTransform' usage, automatically injecting necessary runtime dependencies into the environment.
  • Consistency Verification: Added a new test script to ensure that the ML dependency versions used in the YAML template remain consistent with the versions defined in the Apache Beam 'setup.py' file.
  • CI/CD Updates: Updated existing GitHub Actions to include unit tests for the YAML template and added a new workflow to validate dependency version consistency.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/yaml-ml-dependencies.yml
    • .github/workflows/yaml-pr.yml
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. ↩

@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 dynamic resolution of runtime dependencies for ML transforms in Beam YAML pipelines. It adds a new module ml_dependencies.py to parse YAML pipelines and identify additional dependencies (such as PyTorch, TensorFlow, and Sentence Transformers) when the 'ML' experimental feature is enabled, along with a validation script and comprehensive tests. The feedback highlights a critical Python 3.8 compatibility issue with argparse.ArgumentParser's exit_on_error parameter, and suggests improvements such as making the framework string check case-insensitive, passing a copy of arguments defensively, and explicitly specifying UTF-8 encoding when opening files across the codebase.

Comment thread python/src/main/python/yaml-template/ml_dependencies.py
Comment thread python/src/main/python/yaml-template/ml_dependencies.py
Comment thread python/src/main/python/yaml-template/ml_dependencies.py
Comment thread python/src/main/python/yaml-template/main.py
Comment thread python/src/test/python/yaml-template/check_ml_dependencies.py Outdated
Comment thread python/src/test/python/yaml-template/main_test.py
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.03%. Comparing base (045ac49) to head (3f2ca3f).
⚠️ Report is 1 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (045ac49) and HEAD (3f2ca3f). Click for more details.

HEAD has 11 uploads less than BASE
Flag BASE (045ac49) HEAD (3f2ca3f)
12 1
Additional details and impacted files
@@              Coverage Diff              @@
##               main    #4443       +/-   ##
=============================================
- Coverage     57.02%   38.03%   -19.00%     
+ Complexity     8031      518     -7513     
=============================================
  Files          1156      195      -961     
  Lines         73749    11885    -61864     
  Branches       8696     1213     -7483     
=============================================
- Hits          42058     4520    -37538     
+ Misses        28892     6994    -21898     
+ Partials       2799      371     -2428     
Components Coverage Δ
spanner-templates ∅ <ø> (∅)
spanner-import-export ∅ <ø> (∅)
spanner-live-forward-migration ∅ <ø> (∅)
spanner-live-reverse-replication ∅ <ø> (∅)
spanner-bulk-migration ∅ <ø> (∅)
gcs-spanner-dv ∅ <ø> (∅)
see 986 files with indirect coverage changes
🚀 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.

@chamikaramj chamikaramj added addition New feature or request and removed size/XL labels Oct 15, 2026
@chamikaramj chamikaramj reopened this Oct 16, 2026
The workflow (.github/workflows/yaml-ml-dependencies.yml) and the script that it runs (python/src/test/python/yaml-template/check_ml_dependencies.py) will be added in a follow-up PR to keep this PR smaller.
@chamikaramj

Copy link
Copy Markdown
Contributor Author

@damccorm @derrickaw PTAL.

Comment thread python/src/main/python/yaml-template/ml_dependencies.py
Comment thread python/src/main/python/yaml-template/ml_dependencies.py

@chamikaramj chamikaramj left a comment

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.

Thanks!

Comment thread python/src/main/python/yaml-template/ml_dependencies.py
Comment thread python/src/main/python/yaml-template/ml_dependencies.py

@damccorm damccorm 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.

Thanks - I think this is a step in the right direction. I am also interested in simplifying in the future since we're effectively taking on some technical debt here.

@chamikaramj
chamikaramj merged commit 53fcc94 into GoogleCloudPlatform:main Oct 23, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

addition New feature or request size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants