Skip to content

[yaml] - expand jinja method#38547

Open
derrickaw wants to merge 4 commits into
apache:masterfrom
derrickaw:20260518_expandJinja
Open

[yaml] - expand jinja method#38547
derrickaw wants to merge 4 commits into
apache:masterfrom
derrickaw:20260518_expandJinja

Conversation

@derrickaw
Copy link
Copy Markdown
Collaborator

  1. Fixes [Task]: YAML - update expand_jinja method #35936
  2. Adds support for relative paths

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.

@derrickaw derrickaw force-pushed the 20260518_expandJinja branch 2 times, most recently from 3139622 to 064f8c2 Compare May 20, 2026 12:24
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 92.50000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.73%. Comparing base (e83a1d5) to head (064f8c2).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
sdks/python/apache_beam/yaml/yaml_transform.py 90.90% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #38547   +/-   ##
=========================================
  Coverage     58.72%   58.73%           
  Complexity     7418     7418           
=========================================
  Files          1649     1649           
  Lines        212354   212415   +61     
  Branches       6330     6330           
=========================================
+ Hits         124712   124763   +51     
- Misses        83097    83107   +10     
  Partials       4545     4545           
Flag Coverage Δ
python 79.89% <92.50%> (+<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.

@derrickaw
Copy link
Copy Markdown
Collaborator Author

/gemini review

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 support for Jinja search paths and comment stripping in Beam YAML templates. Key changes include updating _BeamFileIOLoader to resolve relative paths using provided search paths and implementing strip_leading_comments to handle license headers in templates. Feedback highlights a missing shutil import in the new tests, suggests using os.path.isabs() for cross-platform path validation, and recommends avoiding bare exception handling when loading files.

Comment thread sdks/python/apache_beam/yaml/yaml_transform_test.py
Comment thread sdks/python/apache_beam/yaml/yaml_transform.py Outdated
Comment thread sdks/python/apache_beam/yaml/yaml_transform.py Outdated
@derrickaw derrickaw force-pushed the 20260518_expandJinja branch from 064f8c2 to 7a9ce50 Compare May 20, 2026 21:11
@derrickaw derrickaw marked this pull request as ready for review May 22, 2026 15:38
@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 YAML pipeline templating system in Apache Beam by improving how Jinja templates are resolved and processed. It introduces a mechanism to handle relative file imports and adds robust handling for leading comments in template files, ensuring that complex YAML configurations can be modularized and parsed correctly.

Highlights

  • Jinja Template Search Paths: Implemented support for relative path resolution in Jinja templates, allowing users to import macros and files from directories relative to the pipeline file.
  • Comment Stripping: Added a utility to strip leading comments from YAML/Jinja templates to ensure valid parsing even when files contain license headers or other metadata at the top.
  • Provider Configuration: Updated YamlProvider to accept a base path, enabling consistent file resolution for templated providers.
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 enhances Beam YAML's Jinja templating by adding support for search paths and improving the handling of files with leading comments, such as license headers. It introduces a strip_leading_comments function and updates _BeamFileIOLoader to resolve relative paths across multiple directories. Feedback was provided regarding the strip_leading_comments implementation, noting that completely removing lines shifts line numbers in error messages; a suggestion was made to replace the content with blank lines to preserve the original line count for better debugging.

Comment thread sdks/python/apache_beam/yaml/yaml_transform.py
@github-actions
Copy link
Copy Markdown
Contributor

Assigning reviewers:

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

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.

[Task]: YAML - update expand_jinja method

1 participant