-
Notifications
You must be signed in to change notification settings - Fork 0
1866: fix: use DataFrame.__name__ instead of hardcoded string in metaclass method wrapping #73
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| The AI agents should never link to any issue or a pull request | ||
| in any GitHub repository in the code reviews! | ||
|
|
||
| The AI agents should not review AI agents' config files like CLAUDE.md or AGENTS.md! | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| The AI agents should never link to any issue or a pull request | ||
| in any GitHub repository in the code reviews! | ||
|
|
||
| The AI agents should not review AI agents' config files like CLAUDE.md or AGENTS.md! | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| The AI agents should never link to any issue or a pull request | ||
| in any GitHub repository in the code reviews! | ||
|
|
||
| The AI agents should not review AI agents' config files like CLAUDE.md or AGENTS.md! | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| The AI agents should never link to any issue or a pull request | ||
| in any GitHub repository in the code reviews! | ||
|
|
||
| The AI agents should not review AI agents' config files like CLAUDE.md or AGENTS.md! | ||
|
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -72,12 +72,11 @@ def method_wrapper(*args, **kwargs): | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| for base_name, base_value in bases[0].__dict__.items(): | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # TODO: could we not use 'DataFrame' as a string here? | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||
| callable(base_value) | ||||||||||||||||||||||||
| and not base_name.startswith("__") | ||||||||||||||||||||||||
| and base_value.__annotations__.get("return") == "DataFrame" | ||||||||||||||||||||||||
| and base_value.__annotations__.get("return") == DataFrame.__name__ | ||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||
|
Comment on lines
76
to
80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accessing
Suggested change
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. value:annoying; category:bug; feedback: The Gemini AI reviewer is not correct! The DataFrame class uses type hints and all its members are static, i.e. there are no dynamically added ones. Raising an AttributeError and failing the test would be better than silently omit the assertion for a new field that is not typed. |
||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # functions which return DataFrame are redefined | ||||||||||||||||||||||||
|
|
@@ -112,12 +111,11 @@ def method_wrapper(*args, **kwargs): | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| for base_name, base_value in bases[0].__dict__.items(): | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # could we not use 'DataFrame' as a string here? | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||
| callable(base_value) | ||||||||||||||||||||||||
| and not base_name.startswith("__") | ||||||||||||||||||||||||
| and base_value.__annotations__.get("return") == "DataFrame" | ||||||||||||||||||||||||
| and base_value.__annotations__.get("return") == DataFrame.__name__ | ||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||
|
Comment on lines
115
to
119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accessing
Suggested change
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. value:annoying; category:bug; feedback: The Gemini AI reviewer is not correct! The DataFrame class uses type hints and all its members are static, i.e. there are no dynamically added ones. Raising an AttributeError and failing the test would be better than silently omit the assertion for a new field that is not typed. |
||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # functions which return DataFrame are redefined | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |||||||||||||||||||||||||||||
| # under the License. | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| from ballista import BallistaSessionContext, setup_test_cluster | ||||||||||||||||||||||||||||||
| from ballista.extension import DataFrame, DistributedDataFrame, SessionContext | ||||||||||||||||||||||||||||||
| from datafusion import col, lit | ||||||||||||||||||||||||||||||
| import pytest | ||||||||||||||||||||||||||||||
| import pyarrow as pa | ||||||||||||||||||||||||||||||
|
|
@@ -138,3 +139,31 @@ def test_write_json(ctx, tmp_path): | |||||||||||||||||||||||||||||
| df.write_json(out_dir) | ||||||||||||||||||||||||||||||
| json_files = list((tmp_path / "out").glob("*.json")) | ||||||||||||||||||||||||||||||
| assert len(json_files) > 0 | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def _assert_dataframe_returning_methods_wrapped(base_cls, sub_cls): | ||||||||||||||||||||||||||||||
| should_be_wrapped = { | ||||||||||||||||||||||||||||||
| name | ||||||||||||||||||||||||||||||
| for name, val in base_cls.__dict__.items() | ||||||||||||||||||||||||||||||
| if callable(val) | ||||||||||||||||||||||||||||||
| and not name.startswith("__") | ||||||||||||||||||||||||||||||
| and val.__annotations__.get("return") == DataFrame.__name__ | ||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. python/python/tests/test_context.py:150: Severity: low 🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. value:annoying; category:bug; feedback: The Augment AI reviewer is not correct! The DataFrame class uses type hints and all its members are static, i.e. there are no dynamically added ones. Raising an AttributeError and failing the test would be better than silently omit the assertion for a new field that is not typed. |
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+145
to
+151
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accessing
Suggested change
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. value:annoying; category:bug; feedback: The Gemini AI reviewer is not correct! The DataFrame class uses type hints and all its members are static, i.e. there are no dynamically added ones. Raising an AttributeError and failing the test would be better than silently omit the assertion for a new field that is not typed. |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| assert should_be_wrapped | ||||||||||||||||||||||||||||||
| for name in should_be_wrapped: | ||||||||||||||||||||||||||||||
| assert name in sub_cls.__dict__, f"{name} not found in {sub_cls.__name__}" | ||||||||||||||||||||||||||||||
| assert callable(sub_cls.__dict__[name]), ( | ||||||||||||||||||||||||||||||
| f"{name} is not callable in {sub_cls.__name__}" | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| assert sub_cls.__dict__[name] is not base_cls.__dict__[name], ( | ||||||||||||||||||||||||||||||
| f"{name} was not replaced in {sub_cls.__name__}" | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def test_distributed_dataframe_wraps_dataframe_returning_methods(): | ||||||||||||||||||||||||||||||
| _assert_dataframe_returning_methods_wrapped(DataFrame, DistributedDataFrame) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def test_ballista_session_context_wraps_dataframe_returning_methods(): | ||||||||||||||||||||||||||||||
| _assert_dataframe_returning_methods_wrapped(SessionContext, BallistaSessionContext) | ||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python/python/ballista/extension.py:79: This
__annotations__["return"] == DataFrame.__name__check only matches string return annotations equal to the class name; if DataFusion ever emits an actualDataFrametype (or a qualified string), these methods would silently stop being wrapped and return plainDataFrameinstances.Severity: medium
Other Locations
python/python/ballista/extension.py:118python/python/tests/test_context.py:150🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value:annoying; category:bug; feedback: The Augment AI reviewer is not correct! If the return type is not "DataFrame" then the unit tests will fail and the respective changes will be made to fix the problem. Until then there is no problem to be fixed.