You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "caneff (via GitHub)" <gi...@apache.org> on 2023/09/14 15:45:49 UTC
[GitHub] [beam] caneff opened a new pull request, #28454: Support kw only arguments for frame methods for Pandas 2
caneff opened a new pull request, #28454:
URL: https://github.com/apache/beam/pull/28454
Pandas 2 turns most args of most of its methods into kwonly args.
args_to_kwargs and populate_defaults needed to be changed to look there, and there were a few locations that called pandas methods by location only that had to be updated to call by keyword.
Partially fixes #27221.
--
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
[GitHub] [beam] tvalentyn commented on pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn commented on PR #28454:
URL: https://github.com/apache/beam/pull/28454#issuecomment-1721714521
Run Python PreCommit
--
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
[GitHub] [beam] caneff commented on a diff in pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "caneff (via GitHub)" <gi...@apache.org>.
caneff commented on code in PR #28454:
URL: https://github.com/apache/beam/pull/28454#discussion_r1327587669
##########
sdks/python/apache_beam/dataframe/frame_base.py:
##########
@@ -500,6 +500,8 @@ def wrap(func):
removed_arg_names = removed_args if removed_args is not None else []
+ # TODO: Better handle position only arguments if they are ever a thing
Review Comment:
Removed the TODO
--
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
[GitHub] [beam] caneff commented on a diff in pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "caneff (via GitHub)" <gi...@apache.org>.
caneff commented on code in PR #28454:
URL: https://github.com/apache/beam/pull/28454#discussion_r1327592167
##########
sdks/python/apache_beam/dataframe/frame_base_test.py:
##########
@@ -72,7 +72,7 @@ def add_one(frame):
def test_args_to_kwargs(self):
class Base(object):
- def func(self, a=1, b=2, c=3):
+ def func(self, a=1, b=2, c=3, *, kw_only=4):
Review Comment:
Done
--
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
[GitHub] [beam] github-actions[bot] commented on pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #28454:
URL: https://github.com/apache/beam/pull/28454#issuecomment-1719713469
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control
--
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
[GitHub] [beam] caneff commented on pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "caneff (via GitHub)" <gi...@apache.org>.
caneff commented on PR #28454:
URL: https://github.com/apache/beam/pull/28454#issuecomment-1719853285
Run Python_Runners PreCommit
--
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
[GitHub] [beam] caneff commented on a diff in pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "caneff (via GitHub)" <gi...@apache.org>.
caneff commented on code in PR #28454:
URL: https://github.com/apache/beam/pull/28454#discussion_r1327592711
##########
sdks/python/apache_beam/dataframe/frame_base_test.py:
##########
@@ -129,6 +132,45 @@ def func_removed_args(self, a, c, **kwargs):
proxy.func_removed_args()
self.assertEqual(proxy.func_removed_args(12, d=100), {'a': 12, 'd': 100})
+ def test_args_to_kwargs_populates_default_handles_kw_only(self):
+ class Base(object):
+ def func(self, a=1, b=2, c=3, *, kw_only=4):
+ pass
+
+ class ProxyUsesKwOnly(object):
+ @frame_base.args_to_kwargs(Base)
+ @frame_base.populate_defaults(Base)
+ def func(self, a, kw_only, **kwargs):
+ return dict(kwargs, a=a, kw_only=kw_only)
+
+ proxy = ProxyUsesKwOnly()
+
+ # pylint: disable=too-many-function-args,no-value-for-parameter
+ self.assertEqual(proxy.func(), {'a': 1, 'kw_only': 4})
+ self.assertEqual(proxy.func(100), {'a': 100, 'kw_only': 4})
+ self.assertEqual(
+ proxy.func(2, 4, 6, kw_only=8), {
+ 'a': 2, 'b': 4, 'c': 6, 'kw_only': 8
+ })
+ with self.assertRaises(TypeError):
+ proxy.func(2, 4, 6, 8) # got too many positioned arguments
+
+ class ProxyDoesntUseKwOnly(object):
+ @frame_base.args_to_kwargs(Base)
+ @frame_base.populate_defaults(Base)
+ def func(self, a, **kwargs):
+ return dict(kwargs, a=a)
+
+ proxy = ProxyDoesntUseKwOnly()
+
+ # pylint: disable=too-many-function-args,no-value-for-parameter
+ self.assertEqual(proxy.func(), {'a': 1})
Review Comment:
Because this is only populating defaults for the proxy function. `b`, `c` and `kw_only` are not arguments in the proxy function
--
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
[GitHub] [beam] tvalentyn commented on a diff in pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn commented on code in PR #28454:
URL: https://github.com/apache/beam/pull/28454#discussion_r1327523320
##########
sdks/python/apache_beam/dataframe/frame_base.py:
##########
@@ -500,6 +500,8 @@ def wrap(func):
removed_arg_names = removed_args if removed_args is not None else []
+ # TODO: Better handle position only arguments if they are ever a thing
Review Comment:
Sounds like we could remove this TODO. If you think we should keep it, would you mind expanding on what 'better' would mean? Thanks!
##########
sdks/python/apache_beam/dataframe/frame_base_test.py:
##########
@@ -72,7 +72,7 @@ def add_one(frame):
def test_args_to_kwargs(self):
class Base(object):
- def func(self, a=1, b=2, c=3):
+ def func(self, a=1, b=2, c=3, *, kw_only=4):
Review Comment:
would it make sense to also include an argument without a default in this or antoher test case?
##########
sdks/python/apache_beam/dataframe/frame_base_test.py:
##########
@@ -129,6 +132,45 @@ def func_removed_args(self, a, c, **kwargs):
proxy.func_removed_args()
self.assertEqual(proxy.func_removed_args(12, d=100), {'a': 12, 'd': 100})
+ def test_args_to_kwargs_populates_default_handles_kw_only(self):
+ class Base(object):
+ def func(self, a=1, b=2, c=3, *, kw_only=4):
+ pass
+
+ class ProxyUsesKwOnly(object):
+ @frame_base.args_to_kwargs(Base)
+ @frame_base.populate_defaults(Base)
+ def func(self, a, kw_only, **kwargs):
+ return dict(kwargs, a=a, kw_only=kw_only)
+
+ proxy = ProxyUsesKwOnly()
+
+ # pylint: disable=too-many-function-args,no-value-for-parameter
+ self.assertEqual(proxy.func(), {'a': 1, 'kw_only': 4})
+ self.assertEqual(proxy.func(100), {'a': 100, 'kw_only': 4})
+ self.assertEqual(
+ proxy.func(2, 4, 6, kw_only=8), {
+ 'a': 2, 'b': 4, 'c': 6, 'kw_only': 8
+ })
+ with self.assertRaises(TypeError):
+ proxy.func(2, 4, 6, 8) # got too many positioned arguments
+
+ class ProxyDoesntUseKwOnly(object):
+ @frame_base.args_to_kwargs(Base)
+ @frame_base.populate_defaults(Base)
+ def func(self, a, **kwargs):
+ return dict(kwargs, a=a)
+
+ proxy = ProxyDoesntUseKwOnly()
+
+ # pylint: disable=too-many-function-args,no-value-for-parameter
+ self.assertEqual(proxy.func(), {'a': 1})
Review Comment:
Why is it that in this case the `a=1` default is populated, but `b=2`, `c=3`, `kw_only=4` are not?
--
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
[GitHub] [beam] caneff commented on pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "caneff (via GitHub)" <gi...@apache.org>.
caneff commented on PR #28454:
URL: https://github.com/apache/beam/pull/28454#issuecomment-1719711299
R: @tvalentyn
--
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
[GitHub] [beam] tvalentyn commented on pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn commented on PR #28454:
URL: https://github.com/apache/beam/pull/28454#issuecomment-1724351650
Run Python PreCommit
--
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
[GitHub] [beam] codecov[bot] commented on pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #28454:
URL: https://github.com/apache/beam/pull/28454#issuecomment-1719881378
## [Codecov](https://app.codecov.io/gh/apache/beam/pull/28454?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
> Merging [#28454](https://app.codecov.io/gh/apache/beam/pull/28454?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (85bc52c) into [master](https://app.codecov.io/gh/apache/beam/commit/5696c59f224949e390b0a72ec80e47c0c9bf1bda?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (5696c59) will **decrease** coverage by `0.02%`.
> Report is 3 commits behind head on master.
> The diff coverage is `100.00%`.
```diff
@@ Coverage Diff @@
## master #28454 +/- ##
==========================================
- Coverage 72.33% 72.32% -0.02%
==========================================
Files 683 683
Lines 100709 100701 -8
==========================================
- Hits 72848 72828 -20
- Misses 26281 26295 +14
+ Partials 1580 1578 -2
```
| [Flag](https://app.codecov.io/gh/apache/beam/pull/28454/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [python](https://app.codecov.io/gh/apache/beam/pull/28454/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `82.82% <100.00%> (+<0.01%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Files Changed](https://app.codecov.io/gh/apache/beam/pull/28454?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [sdks/python/apache\_beam/dataframe/frames.py](https://app.codecov.io/gh/apache/beam/pull/28454?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0vZGF0YWZyYW1lL2ZyYW1lcy5weQ==) | `95.37% <ø> (ø)` | |
| [sdks/python/apache\_beam/dataframe/frame\_base.py](https://app.codecov.io/gh/apache/beam/pull/28454?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0vZGF0YWZyYW1lL2ZyYW1lX2Jhc2UucHk=) | `89.45% <100.00%> (+0.20%)` | :arrow_up: |
... and [8 files with indirect coverage changes](https://app.codecov.io/gh/apache/beam/pull/28454/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
--
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
[GitHub] [beam] caneff commented on pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "caneff (via GitHub)" <gi...@apache.org>.
caneff commented on PR #28454:
URL: https://github.com/apache/beam/pull/28454#issuecomment-1719852502
Run Python_Coverage PreCommit
--
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
[GitHub] [beam] tvalentyn commented on pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn commented on PR #28454:
URL: https://github.com/apache/beam/pull/28454#issuecomment-1721714800
Run Python_Runners PreCommit
--
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
[GitHub] [beam] tvalentyn merged pull request #28454: Support kw only arguments for frame methods for Pandas 2
Posted by "tvalentyn (via GitHub)" <gi...@apache.org>.
tvalentyn merged PR #28454:
URL: https://github.com/apache/beam/pull/28454
--
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