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

Add LogElements as a Beam PTransform #23879

Merged
merged 9 commits into from Nov 1, 2022
Merged

Conversation

nivaldoh
Copy link
Contributor

Closes #23016

Adds LogElements as a valid PTransform with unit tests and updates the previous references to the standalone transform in the katas section.


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.

@nivaldoh
Copy link
Contributor Author

R: @tvalentyn

@github-actions
Copy link
Contributor

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

Copy link
Contributor

@tvalentyn tvalentyn left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

"event",
datetime(2022, 10, 2, 0, 0, 0, 0,
tzinfo=pytz.UTC).timestamp()),
]) \
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it's generally discouraged to use line continuation symbol. It should be not necessary here given you have parentheses, which ensure statement continuation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, those were leftovers from testing. Removed.

@@ -1105,6 +1105,47 @@ def Iterables(delimiter=None):
Kvs = Iterables


class LogElements(PTransform):
Copy link
Contributor

Choose a reason for hiding this comment

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

please add this class also to __all__ (line 93). this should also make imports simpler thanks to

from apache_beam.transforms.util import *
and
from apache_beam.transforms import *

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -49,7 +49,6 @@ COPY --from=build /go/bin/server_python_backend /opt/playground/backend/
COPY --from=build /go/src/playground/backend/configs /opt/playground/backend/configs/

# Install Python Katas Utils
COPY katas/log_elements.py /go/src/katas/
Copy link
Contributor

Choose a reason for hiding this comment

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

A lot of playground examples have:

from log_elements import LogElements. These statements would stop working, so we should either look how to replace them or for a drop-in replacement keep katas/log_elements.py which will simply import LogElements from util.py

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 apologize in advance if my understanding is wrong, but wouldn't the changes in the kata files (such as this one) correct this problem, as the playground backend would pull the updated Python SDK with the changes there after the merge?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, I think you are right, I didn't realize playground just re-used code from katas.

Copy link
Contributor

Choose a reason for hiding this comment

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

would using beam.LogElements work instead? that sounds like it would make katas code more uniformly looking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The beam.LogElements import does work on the tests I ran, and it's definitely a cleaner way to import the transform. I made a new commit with this update.

@@ -1105,6 +1105,47 @@ def Iterables(delimiter=None):
Kvs = Iterables


class LogElements(PTransform):
Copy link
Contributor

Choose a reason for hiding this comment

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

let's also add typehints like in Reshuffle, see: line 772-773

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typehints added!

@tvalentyn
Copy link
Contributor

Re Lint errors, you cand find them in Details -> ConsoleOutput, e.g. https://ci-beam.apache.org/job/beam_PreCommit_PythonLint_Commit/16316/consoleText

See also: s.apache.org/beam-python-dev-wiki that mentions lint/autoformatting tools

@codecov
Copy link

codecov bot commented Oct 28, 2022

Codecov Report

Merging #23879 (3223001) into master (abb932e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master   #23879   +/-   ##
=======================================
  Coverage   73.85%   73.85%           
=======================================
  Files         707      707           
  Lines       95746    95771   +25     
=======================================
+ Hits        70710    70732   +22     
- Misses      23720    23723    +3     
  Partials     1316     1316           
Flag Coverage Δ
python 83.79% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
sdks/python/apache_beam/transforms/util.py 96.21% <100.00%> (+0.14%) ⬆️
.../python/apache_beam/transforms/periodicsequence.py 98.38% <0.00%> (-1.62%) ⬇️
sdks/python/apache_beam/io/source_test_utils.py 88.01% <0.00%> (-1.39%) ⬇️
sdks/python/apache_beam/utils/interactive_utils.py 97.56% <0.00%> (+2.43%) ⬆️

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

@nivaldoh
Copy link
Contributor Author

@tvalentyn Thank you for the quick response! All points have been fully addressed except for this one, where I kindly asked you to clarify a piece of information before proceeding.

@tvalentyn
Copy link
Contributor

Thanks, this looks good to me. Test failures are unrelated.

@tvalentyn tvalentyn merged commit 3371a1c into apache:master Nov 1, 2022
@tvalentyn
Copy link
Contributor

cc: @damccorm fyi.

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.

[Feature Request]: Move LogElements transform to Beam Transforms
2 participants