Skip to content

Conversation

@liferoad
Copy link
Contributor

@liferoad liferoad commented Mar 7, 2023

addresses #22969:

Do not allow mixing yield and return statements in the process method for DoFn


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.

@github-actions github-actions bot added the python label Mar 7, 2023
@liferoad
Copy link
Contributor Author

liferoad commented Mar 7, 2023

@tvalentyn PTAL.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2023

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2023

Assigning reviewers. If you would like to opt out of this review, comment assign to next reviewer:

R: @pabloem for label python.

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).

@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Merging #25743 (b979176) into master (d9f81b8) will decrease coverage by 0.03%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #25743      +/-   ##
==========================================
- Coverage   71.44%   71.42%   -0.03%     
==========================================
  Files         777      777              
  Lines      102275   102395     +120     
==========================================
+ Hits        73075    73140      +65     
- Misses      27745    27800      +55     
  Partials     1455     1455              
Flag Coverage Δ
python 79.96% <100.00%> (-0.05%) ⬇️

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

Impacted Files Coverage Δ
sdks/python/apache_beam/transforms/core.py 93.14% <100.00%> (+0.22%) ⬆️

... and 17 files with indirect coverage changes

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

@liferoad
Copy link
Contributor Author

Run PythonDocker PreCommit

@liferoad liferoad requested a review from tvalentyn March 11, 2023 20:06
@liferoad liferoad requested a review from tvalentyn March 17, 2023 13:46
@liferoad liferoad requested a review from tvalentyn March 20, 2023 18:34
@tvalentyn tvalentyn merged commit 9a5e5b8 into apache:master Mar 21, 2023
@tvalentyn tvalentyn changed the title Raise the Runtime error when DoFn.process uses both yield and return Warn when DoFn.process uses both yield and return Mar 22, 2023
@shunping
Copy link
Collaborator

shunping commented Dec 19, 2025

Just noticed that the dofn used by PeriodicImpulse was also flagged for this:

WARNING:apache_beam.transforms.core:Using yield and return in the process method of <class 'apache_beam.transforms.periodicsequence.ImpulseSeqGenDoFn'> can lead to unexpected behavior, see:https://github.com/apache/beam/issues/22969.

@tvalentyn
Copy link
Contributor

I think it is harmless since we are not returning anything, but #37153 should remove the warning.

@shunping
Copy link
Collaborator

Found another one:)

WARNING:apache_beam.transforms.core:Using yield and return in the process method of <class 'apache_beam.io.fileio._ReadMatchesFn'> can lead to unexpected behavior, see:https://github.com/apache/beam/issues/22969.

class _ReadMatchesFn(beam.DoFn):

This looks like harmless as the previous one.

Maybe it is better to only give a warning if yield and return in the same function AND some of the returns are returning something?

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.

3 participants