Skip to content

Commit f2d5264

Browse files
authored
fix: exclude DataFrame and Series __call__ from unimplemented API metrics (#1351)
* fix: add feedback link to `DataFrame` and `Series` `__call__` error * revert __call__ add to unimplemented tracking
1 parent e86a4da commit f2d5264

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

bigframes/core/log_adapter.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def submit_pandas_labels(
7878
else:
7979
return
8080

81-
if hasattr(cls, method_name):
81+
# Omit __call__, because its not implemented on the actual instances of
82+
# DataFrame/Series, only as the constructor.
83+
if method_name != "__call__" and hasattr(cls, method_name):
8284
method = getattr(cls, method_name)
8385
else:
8486
return

tests/unit/core/test_log_adapter.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,31 @@ def test_submit_pandas_labels_without_valid_params_for_param_logging(mock_bqclie
157157
mock_bqclient.query.assert_not_called()
158158

159159

160-
def test_submit_pandas_labels_with_internal_method(mock_bqclient):
160+
@pytest.mark.parametrize(
161+
("class_name", "method_name"),
162+
(
163+
("Series", "_repr_latex_"),
164+
(
165+
"DataFrame",
166+
# __call__ should be excluded.
167+
# It's implemented on the pd.DataFrame class but not pd.DataFrame instances.
168+
"__call__",
169+
),
170+
(
171+
"Series",
172+
# __call__ should be excluded.
173+
# It's implemented on the pd.Series class but not pd.Series instances.
174+
"__call__",
175+
),
176+
),
177+
)
178+
def test_submit_pandas_labels_with_internal_method(
179+
mock_bqclient, class_name, method_name
180+
):
161181
log_adapter.submit_pandas_labels(
162182
mock_bqclient,
163-
"Series",
164-
"_repr_latex_",
183+
class_name,
184+
method_name,
165185
task=log_adapter.PANDAS_API_TRACKING_TASK,
166186
)
167187
mock_bqclient.query.assert_not_called()

0 commit comments

Comments
 (0)