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

Better errors when inputs are omitted. #28289

Merged
merged 6 commits into from
Sep 18, 2023
Merged

Conversation

robertwb
Copy link
Contributor

@robertwb robertwb commented Sep 2, 2023

It's not always possible to know if a transform consumes inputs, or can act as a root transform (and in fact some may be able to do both depending on their configuration), but when a transform expecting inputs doesn't get them the error can be quite obscure. This adds best-effort checking and a better error in that case.

We also allow explicitly setting empty imputs to work around this error (which is where most of the complexity of this change lies). Importantly, sources (no matter their name) are not required to have inputs.


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.

It's not always possible to know if a transform consumes inputs,
or can act as a root transform (and in fact some may be able to do
both depending on their configuration), but when a transform
expecting inputs doesn't get them the error can be quite obscure.
This adds best-effort checking and a better error in that case.

We also allow explicitly setting empty imputs to work around this
error (which is where most of the complexity of this change lies).
Importantly, sources (no matter their name) are not required to have
inputs.
@github-actions github-actions bot added the python label Sep 2, 2023
@robertwb
Copy link
Contributor Author

robertwb commented Sep 2, 2023

R: @byronellis

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2023

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

@codecov
Copy link

codecov bot commented Sep 2, 2023

Codecov Report

Merging #28289 (889c0cf) into master (881c597) will decrease coverage by 0.02%.
Report is 1 commits behind head on master.
The diff coverage is 83.92%.

@@            Coverage Diff             @@
##           master   #28289      +/-   ##
==========================================
- Coverage   72.26%   72.25%   -0.02%     
==========================================
  Files         684      684              
  Lines      100842   100937      +95     
==========================================
+ Hits        72878    72931      +53     
- Misses      26384    26426      +42     
  Partials     1580     1580              
Flag Coverage Δ
python 82.83% <83.92%> (-0.04%) ⬇️

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

Files Changed Coverage Δ
sdks/python/apache_beam/yaml/yaml_provider.py 70.37% <69.56%> (+0.28%) ⬆️
sdks/python/apache_beam/yaml/yaml_transform.py 90.61% <93.93%> (+0.25%) ⬆️

... and 10 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@byronellis byronellis left a comment

Choose a reason for hiding this comment

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

I don't know there's much we can do about schematransform's design other than leaving a couple of comments here--that's way out of the scope of YAML and would require breaking changes to expansionservices (or a new API)


This is best-effort, primarily for better and earlier error messages.
"""
return not typ.startswith('Read')
Copy link
Contributor

Choose a reason for hiding this comment

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

Presuming this is to provide a reasonable default? Seems like it might lead to surprising false positives though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, just a reasonable default. Most transforms that do not start with Read require an input by, the main exception being SQL (where we can't tell and the "typical" use of selecting on PCollection would be good to error on). One can explicitly state inputs: [] to suppress this error.


def requires_inputs(self, typ, args):
if self._urns[type] in self.schema_transforms():
return bool(self.schema_transforms()[self._urns[type]].inputs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately relying on schema transform's inputs/outputs is not very reliable (and maybe completely unreliable). They do not depend on the configuration passed to the transforms making them basically useless for determining anything other than inputs/outputs that are present in all possible configurations.

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, it'd be nice to be able to query about the requirements of a configured transform before invoking it, but that's a larger change... Most (though not all) transforms have fixed inputs at least, so this'll cover those.

@robertwb robertwb merged commit 3024ec2 into apache:master Sep 18, 2023
75 of 77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants