Skip to content

fix: exclude DataFrame and Series __call__ from unimplemented API metrics #1351

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

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bigframes/core/log_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def submit_pandas_labels(
else:
return

if hasattr(cls, method_name):
# Omit __call__, because its not implemented on the actual instances of
# DataFrame/Series, only as the constructor.
if method_name != "__call__" and hasattr(cls, method_name):
method = getattr(cls, method_name)
else:
return
Expand Down
26 changes: 23 additions & 3 deletions tests/unit/core/test_log_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,31 @@ def test_submit_pandas_labels_without_valid_params_for_param_logging(mock_bqclie
mock_bqclient.query.assert_not_called()


def test_submit_pandas_labels_with_internal_method(mock_bqclient):
@pytest.mark.parametrize(
("class_name", "method_name"),
(
("Series", "_repr_latex_"),
(
"DataFrame",
# __call__ should be excluded.
# It's implemented on the pd.DataFrame class but not pd.DataFrame instances.
"__call__",
),
(
"Series",
# __call__ should be excluded.
# It's implemented on the pd.Series class but not pd.Series instances.
"__call__",
),
),
)
def test_submit_pandas_labels_with_internal_method(
mock_bqclient, class_name, method_name
):
log_adapter.submit_pandas_labels(
mock_bqclient,
"Series",
"_repr_latex_",
class_name,
method_name,
task=log_adapter.PANDAS_API_TRACKING_TASK,
)
mock_bqclient.query.assert_not_called()