You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "jrmccluskey (via GitHub)" <gi...@apache.org> on 2025/04/22 14:50:44 UTC
[PR] Fix handling of collections.Counter types [beam]
jrmccluskey opened a new pull request, #34706:
URL: https://github.com/apache/beam/pull/34706
`collections.Counter` types are special dictionary cases where they generally only accept one type parameter to act as the key, while the value is implicitly always an `int`. Beam incorrectly handled these types when properly hinted with only one type, as they are dictionaries but were only being defined with arity 1 instead of 2. This adds a check to correct this issue and an associated test case.
------------------------
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](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix handling of collections.Counter types [beam]
Posted by "jrmccluskey (via GitHub)" <gi...@apache.org>.
jrmccluskey merged PR #34706:
URL: https://github.com/apache/beam/pull/34706
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix handling of collections.Counter types [beam]
Posted by "jrmccluskey (via GitHub)" <gi...@apache.org>.
jrmccluskey commented on code in PR #34706:
URL: https://github.com/apache/beam/pull/34706#discussion_r2063772266
##########
sdks/python/apache_beam/typehints/native_type_compatibility_test.py:
##########
@@ -263,6 +263,10 @@ def test_convert_to_beam_type_with_collections_types(self):
collections.defaultdict[str, int],
typehints.Dict[str, int]),
('count', collections.Counter[str, int], typehints.Dict[str, int]),
Review Comment:
This is not genuinely considered a correct use case, no. On the beam side a `Counter[str, str]` hint would be treated as a `Dict[str, str]` just from processing, but it wouldn't be satisfied by a proper usage of a counter in a pipeline and throw an error.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix handling of collections.Counter types [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #34706:
URL: https://github.com/apache/beam/pull/34706#issuecomment-2828557196
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`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix handling of collections.Counter types [beam]
Posted by "jrmccluskey (via GitHub)" <gi...@apache.org>.
jrmccluskey commented on PR #34706:
URL: https://github.com/apache/beam/pull/34706#issuecomment-2824480286
assign to next reviewer
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix handling of collections.Counter types [beam]
Posted by "jrmccluskey (via GitHub)" <gi...@apache.org>.
jrmccluskey commented on PR #34706:
URL: https://github.com/apache/beam/pull/34706#issuecomment-2828554242
R: @shunping
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix handling of collections.Counter types [beam]
Posted by "shunping (via GitHub)" <gi...@apache.org>.
shunping commented on code in PR #34706:
URL: https://github.com/apache/beam/pull/34706#discussion_r2059048226
##########
sdks/python/apache_beam/typehints/native_type_compatibility_test.py:
##########
@@ -263,6 +263,10 @@ def test_convert_to_beam_type_with_collections_types(self):
collections.defaultdict[str, int],
typehints.Dict[str, int]),
('count', collections.Counter[str, int], typehints.Dict[str, int]),
Review Comment:
Is this considered a correct use case? Also what happens if a user provides `collections.Counter[str, str]`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix handling of collections.Counter types [beam]
Posted by "jrmccluskey (via GitHub)" <gi...@apache.org>.
jrmccluskey commented on code in PR #34706:
URL: https://github.com/apache/beam/pull/34706#discussion_r2063773575
##########
sdks/python/apache_beam/typehints/native_type_compatibility_test.py:
##########
@@ -263,6 +263,10 @@ def test_convert_to_beam_type_with_collections_types(self):
collections.defaultdict[str, int],
typehints.Dict[str, int]),
('count', collections.Counter[str, int], typehints.Dict[str, int]),
Review Comment:
I will likely remove this test case in a follow-up, but will handle that later
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix handling of collections.Counter types [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #34706:
URL: https://github.com/apache/beam/pull/34706#issuecomment-2821812131
Assigning reviewers. If you would like to opt out of this review, comment `assign to next reviewer`:
R: @damccorm 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).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org