Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 6557d90

Browse files
committed
feat(core): export execution_history from base namespace instead of pandas
1 parent d0afa91 commit 6557d90

File tree

5 files changed

+17
-21
lines changed

5 files changed

+17
-21
lines changed

bigframes/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from bigframes._config.bigquery_options import BigQueryOptions # noqa: E402
2929
from bigframes.core.global_session import ( # noqa: E402
3030
close_session,
31+
execution_history,
3132
get_global_session,
3233
)
3334
import bigframes.enums as enums # noqa: E402
@@ -57,6 +58,7 @@ def load_ipython_extension(ipython):
5758
"BigQueryOptions",
5859
"get_global_session",
5960
"close_session",
61+
"execution_history",
6062
"enums",
6163
"exceptions",
6264
"connect",

bigframes/core/global_session.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import bigframes.exceptions as bfe
2727

2828
if TYPE_CHECKING:
29+
import pandas
30+
2931
import bigframes.session
3032

3133
_global_session: Optional[bigframes.session.Session] = None
@@ -124,6 +126,14 @@ def with_default_session(func_: Callable[..., _T], *args, **kwargs) -> _T:
124126
return func_(get_global_session(), *args, **kwargs)
125127

126128

129+
def execution_history() -> "pandas.DataFrame":
130+
import pandas # noqa: F401
131+
132+
import bigframes.session
133+
134+
return with_default_session(bigframes.session.Session.execution_history)
135+
136+
127137
class _GlobalSessionContext:
128138
"""
129139
Context manager for testing that sets global session.

bigframes/pandas/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,6 @@ def reset_session():
422422
reset_session.__doc__ = global_session.close_session.__doc__
423423

424424

425-
def execution_history() -> pandas.DataFrame:
426-
return global_session.with_default_session(
427-
bigframes.session.Session.execution_history
428-
)
429-
430-
431-
execution_history.__doc__ = inspect.getdoc(bigframes.session.Session.execution_history)
432-
433-
434425
# SQL Compilation uses recursive algorithms on deep trees
435426
# 10M tree depth should be sufficient to generate any sql that is under bigquery limit
436427
# Note: This limit does not have the desired effect on Python 3.12 in
@@ -454,7 +445,6 @@ def execution_history() -> pandas.DataFrame:
454445
deploy_remote_function,
455446
deploy_udf,
456447
get_default_session_id,
457-
execution_history,
458448
get_dummies,
459449
merge,
460450
qcut,
@@ -490,7 +480,6 @@ def execution_history() -> pandas.DataFrame:
490480
"deploy_remote_function",
491481
"deploy_udf",
492482
"get_default_session_id",
493-
"execution_history",
494483
"get_dummies",
495484
"merge",
496485
"qcut",

notebooks/dataframes/execution_history.ipynb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"id": "e19aa997",
55
"cell_type": "markdown",
66
"source": [
7-
"# Execution History Manual Test\\n\\nThis notebook demonstrates and manually tests the `bigframes.pandas.execution_history()` functionality."
7+
"# Execution History Manual Test\\n\\nThis notebook demonstrates and manually tests the `bigframes.execution_history()` functionality."
88
],
99
"metadata": {},
1010
"execution_count": null
@@ -13,12 +13,7 @@
1313
"id": "84d3ccf6",
1414
"cell_type": "code",
1515
"source": [
16-
"import pandas as pd\n",
17-
"import bigframes.pandas as bpd\n",
18-
"\n",
19-
"# Set options if needed, e.g. project/location\\n\n",
20-
"# bpd.options.bigquery.project = \"YOUR_PROJECT\"\\n\n",
21-
"# bpd.options.bigquery.location = \"US\""
16+
"import pandas as pd\\nimport bigframes.pandas as bpd\\nimport bigframes\\n\\n# Set options if needed, e.g. project/location\\n# bpd.options.bigquery.project = \"YOUR_PROJECT\"\\n# bpd.options.bigquery.location = \"US\""
2217
],
2318
"metadata": {},
2419
"execution_count": null
@@ -95,7 +90,7 @@
9590
"id": "73b3754f",
9691
"cell_type": "code",
9792
"source": [
98-
"history = bpd.execution_history()\\nhistory"
93+
"history = bigframes.execution_history()\\nhistory"
9994
],
10095
"metadata": {},
10196
"execution_count": null

tests/unit/session/test_execution_history.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import google.cloud.bigquery as bigquery
1919
import pandas
2020

21-
import bigframes.pandas as bpd
21+
import bigframes
2222
import bigframes.session
2323
import bigframes.session.metrics as metrics
2424

@@ -60,7 +60,7 @@ def test_pandas_execution_history(monkeypatch):
6060

6161
session._metrics.count_job_stats(query_job=query_job)
6262

63-
df = bpd.execution_history()
63+
df = bigframes.execution_history()
6464

6565
assert isinstance(df, pandas.DataFrame)
6666
assert len(df) == 1

0 commit comments

Comments
 (0)