Skip to content

Commit 9aed207

Browse files
committed
feat: Add debug logs and fix decorator tracking
1 parent eec722a commit 9aed207

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

bigframes/testing/mocks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ def query_and_wait_mock(query, *args, job_config=None, **kwargs):
154154
location=location,
155155
ordering_mode=ordering_mode,
156156
)
157+
158+
# Reset the log adapter to clear any session creation tracking
159+
import bigframes.core.log_adapter as log_adapter
160+
161+
log_adapter.get_and_reset_api_methods()
162+
157163
session = bigframes.Session(context=bqoptions, clients_provider=clients_provider)
158164
session._bq_connection_manager = mock.create_autospec(
159165
bigframes.clients.BqConnectionManager, instance=True

tests/unit/session/test_read_gbq_colab.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ def test_read_gbq_colab_includes_label():
2929
"""Make sure we can tell direct colab usage apart from regular read_gbq usage."""
3030
import bigframes.core.log_adapter as log_adapter
3131

32+
# Monkey patch to track if decorator is called
33+
original_add = log_adapter.add_api_method
34+
called_methods = []
35+
36+
def debug_add_api_method(name):
37+
called_methods.append(name)
38+
print(f"Decorator tracked method: {name}")
39+
return original_add(name)
40+
41+
log_adapter.add_api_method = debug_add_api_method
42+
3243
# Clear any existing call stack and API methods
3344
log_adapter._call_stack.clear()
3445
log_adapter.get_and_reset_api_methods()
@@ -37,8 +48,12 @@ def test_read_gbq_colab_includes_label():
3748

3849
# Ensure call stack is empty before calling the method
3950
log_adapter._call_stack.clear()
51+
print(f"Call stack before call: {log_adapter._call_stack}")
4052

4153
_ = session._read_gbq_colab("SELECT 'read-gbq-colab-test'")
54+
print(f"Call stack after call: {log_adapter._call_stack}")
55+
print(f"Methods tracked by decorator: {called_methods}")
56+
4257
configs = session._job_configs # type: ignore
4358

4459
label_values = []

0 commit comments

Comments
 (0)