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

[Issue#23071] Fix AfterProcessingTime for Python to behave like Java #23100

Merged
merged 4 commits into from
Sep 12, 2022

Conversation

InigoSJ
Copy link
Contributor

@InigoSJ InigoSJ commented Sep 8, 2022

Fixes #23071

Context and examples to show the issue added there.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • 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.

@InigoSJ
Copy link
Contributor Author

InigoSJ commented Sep 8, 2022

R:@pabloem as we discussed, this is the fix

| beam.GroupByKey()
| beam.Map(lambda x: x[1]))

expected = [[i, i + 1]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe this is overly complicated? and we can just assume a fixed value

@github-actions github-actions bot added the python label Sep 8, 2022
@codecov
Copy link

codecov bot commented Sep 8, 2022

Codecov Report

Merging #23100 (4247c8c) into master (ab8a375) will decrease coverage by 0.06%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #23100      +/-   ##
==========================================
- Coverage   73.58%   73.52%   -0.07%     
==========================================
  Files         716      716              
  Lines       95301    95454     +153     
==========================================
+ Hits        70132    70178      +46     
- Misses      23873    23980     +107     
  Partials     1296     1296              
Flag Coverage Δ
python 83.29% <100.00%> (-0.13%) ⬇️

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

Impacted Files Coverage Δ
sdks/python/apache_beam/transforms/trigger.py 90.13% <100.00%> (+0.26%) ⬆️
sdks/python/apache_beam/io/localfilesystem.py 90.97% <0.00%> (-0.76%) ⬇️
...hon/apache_beam/runners/worker/bundle_processor.py 93.54% <0.00%> (-0.13%) ⬇️
...thon/apache_beam/ml/inference/pytorch_inference.py 0.00% <0.00%> (ø)
...am/examples/inference/pytorch_language_modeling.py 0.00% <0.00%> (ø)
sdks/python/apache_beam/runners/common.py 88.71% <0.00%> (+0.12%) ⬆️
...hon/apache_beam/runners/direct/test_stream_impl.py 94.02% <0.00%> (+0.74%) ⬆️
...thon/apache_beam/ml/inference/sklearn_inference.py 96.11% <0.00%> (+1.03%) ⬆️

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

@pabloem
Copy link
Member

pabloem commented Sep 8, 2022

please fix lint : )

@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2022

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

context.set_timer(
'', TimeDomain.REAL_TIME, context.get_current_time() + self.delay)
context.add_state(self.COUNT_TAG, 1)
if context.get_state(self.COUNT_TAG) == 1:
Copy link
Member

Choose a reason for hiding this comment

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

Would this be the correct check?

Suggested change
if context.get_state(self.COUNT_TAG) == 1:
if context.get_state(self.COUNT_TAG) >= 1:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that would make it the same as before, it would increase the timer for every element, we only want to increase if it's the first we see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have modified the logic from a Counter to a State, we don't need to actually count the elements, just modify the timer with the first element in the pane

@InigoSJ
Copy link
Contributor Author

InigoSJ commented Sep 9, 2022

Run Python PreCommit

@pabloem
Copy link
Member

pabloem commented Sep 12, 2022

lgtm!

@pabloem pabloem merged commit f31b277 into apache:master Sep 12, 2022
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.

[Bug]: Python AfterProcessingTime behaves different than Java
2 participants