Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic yaml-defined provider. #31684

Merged
merged 2 commits into from
Jul 3, 2024
Merged

Basic yaml-defined provider. #31684

merged 2 commits into from
Jul 3, 2024

Conversation

robertwb
Copy link
Contributor

This allows one to define new transforms with YAML that can be imported and used in other pipelines.


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.

@robertwb
Copy link
Contributor Author

R: @Polber

Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

Copy link

codecov bot commented Jun 26, 2024

Codecov Report

Attention: Patch coverage is 82.85714% with 6 lines in your changes missing coverage. Please review.

Project coverage is 71.40%. Comparing base (f64aec2) to head (8db31ea).
Report is 40 commits behind head on master.

Files Patch % Lines
sdks/python/apache_beam/yaml/yaml_provider.py 82.85% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #31684      +/-   ##
============================================
+ Coverage     71.37%   71.40%   +0.02%     
  Complexity     1474     1474              
============================================
  Files           900      900              
  Lines        114202   114306     +104     
  Branches       1076     1076              
============================================
+ Hits          81515    81616     +101     
- Misses        30659    30662       +3     
  Partials       2028     2028              
Flag Coverage Δ
python 81.30% <82.85%> (+0.02%) ⬆️

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.

@robertwb
Copy link
Contributor Author

robertwb commented Jul 1, 2024

Ping @Polber

Copy link
Contributor

@Polber Polber left a comment

Choose a reason for hiding this comment

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

Left a couple small comments, but overall I think it looks good and the syntax makes sense to me

Comment on lines 425 to 426
except ImportError:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a warning that validation is unable to be performed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch.

if not isinstance(body, str):
body = yaml.safe_dump(SafeLineLoader.strip_metadata(body))
templated = ( # keep formatting
jinja2.Environment(undefined=jinja2.StrictUndefined)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably use the same logic as main (i.e. allows GCS file includes)

Suggested change
jinja2.Environment(undefined=jinja2.StrictUndefined)
jinja2.Environment(undefined=jinja2.StrictUndefined, loader=_BeamFileIOLoader())

Maybe it would make sense to make a standalone function for loading jinja templates to help keep functionality synced

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'll do that.

This allows one to define new transforms with YAML that can be
imported and used in other pipelines.
Copy link
Contributor Author

@robertwb robertwb left a comment

Choose a reason for hiding this comment

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

PTAL

@robertwb robertwb merged commit 3212688 into apache:master Jul 3, 2024
89 checks passed
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.

2 participants