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 StringSet metrics to Python SDK #31969

Merged
merged 4 commits into from
Jul 30, 2024
Merged

Conversation

Abacn
Copy link
Contributor

@Abacn Abacn commented Jul 24, 2024

Please add a meaningful description for your change here

Direct runner and Flink runner (loopback) working. For Dataflow runner, needs to regenerate apiclient, will be done in a separate PR


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.

@Abacn Abacn marked this pull request as draft July 24, 2024 19:25
@Abacn Abacn force-pushed the pythonstringset branch from d26bd8f to f0276a2 Compare July 24, 2024 22:17
@Abacn Abacn force-pushed the pythonstringset branch from f0276a2 to 8c6a96d Compare July 24, 2024 22:29
@Abacn Abacn marked this pull request as ready for review July 24, 2024 22:46
Copy link
Contributor

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

@Abacn
Copy link
Contributor Author

Abacn commented Jul 25, 2024

R: @robertwb

Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@Abacn Abacn mentioned this pull request Jul 26, 2024
3 tasks
@Abacn
Copy link
Contributor Author

Abacn commented Jul 29, 2024

R: @tvalentyn @robertwb

sdks/python/apache_beam/metrics/cells.py Outdated Show resolved Hide resolved
elif len(y) == 0:
return x
else:
return set.union(x, y)
Copy link
Contributor

Choose a reason for hiding this comment

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

wondering if it makes sense to use return set.union(x, y) unconditionally. Could there be any concerns about side effects due to Aggregation returning a mutable collection that can be modified elsewhere after aggregation was computed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this mirrors #31803 . I wonder in most cases the aggregation encounters one empty and one non-empty cells, so a short cut optimization is reasonable here.

Could there be any concerns about side effects due to Aggregation returning a mutable collection

This is a good point. I was hesitating if I should return set / frozenset . However in Python frozenset isn't instance of set (isinstance(frozenset(), set) is False) while Java ImmutableSet is Set, I ended up with set. Do you think we should make the result of StringSet query a frozenset instance everywhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it depends on the lifecycle of these sets; given Java implementation, my guess is that it is probably not a concern.

sdks/python/apache_beam/metrics/monitoring_infos.py Outdated Show resolved Hide resolved
@Abacn Abacn force-pushed the pythonstringset branch from c967837 to 0e7c297 Compare July 29, 2024 19:29
@Abacn
Copy link
Contributor Author

Abacn commented Jul 30, 2024

PreCommit YAML Xlang Direct fails with slf4jlogger classDefNotFoundError. Test passed on an earlier commit and the change later on are trivial naming changes. Likely bad gradle cache and merging for now

@Abacn Abacn merged commit 17ef888 into apache:master Jul 30, 2024
110 of 111 checks passed
@Abacn Abacn deleted the pythonstringset branch July 30, 2024 14:01
reeba212 pushed a commit to reeba212/beam that referenced this pull request Dec 4, 2024
* Add StringSet metrics to Python SDK

* Address comments

* Use string_set everywhere

* fix leftover SET_STRING_TYPE -> STRING_SET_TYPE
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