-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: support automatic per-cell execution history filtering and isolated callbacks #17144
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
d3bf48c
4258639
7574f22
eccd236
d2eea39
21d5dd8
97c7260
f080dda
4bd2735
9dd03ed
dcae615
eb548b6
7db1330
da6682c
0ef9216
66fe150
b9c9336
5f9d824
d9a5593
0c8f8c7
81bf807
409a2fb
f158662
eb3934b
ee477b8
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 |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ | |
| import datetime | ||
| import threading | ||
| import uuid | ||
| from typing import Any, Callable, Literal, Set | ||
| from typing import Any, Callable, Literal, Optional, Set | ||
|
|
||
| import google.cloud.bigquery._job_helpers | ||
| import google.cloud.bigquery.job.query | ||
|
|
@@ -127,8 +127,21 @@ class Event: | |
|
|
||
| @dataclasses.dataclass(frozen=True) | ||
| class EventEnvelope: | ||
| """An envelope that wraps an execution event with metadata and display options. | ||
|
|
||
| Attributes: | ||
| event: | ||
| The actual execution event details (e.g., ExecutionStarted, BigQuerySentEvent). | ||
| progress_bar: | ||
| Specifies the style of progress bar to display during execution. | ||
| cell_execution_count: | ||
| The 1-indexed execution count of the notebook cell that triggered the event. | ||
| Used to group and filter execution history on a per-cell basis. | ||
| """ | ||
|
|
||
| event: Event | ||
| progress_bar: ProgressBarType = _DEFAULT | ||
| cell_execution_count: Optional[int] = None | ||
|
Contributor
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. Can't figure out what does it mean by just reading the params. Add doc strings to explain this and other parameters.
Contributor
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. Added a clear, comprehensive docstring to the EventEnvelope class in packages/bigframes/bigframes/core/events.py. It now explicitly documents what the wrapper does and describes each parameter, including how cell_execution_count is captured and used to filter and scope execution history on a per-cell basis. |
||
|
|
||
|
|
||
| @dataclasses.dataclass(frozen=True) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -249,3 +249,16 @@ def timedelta_to_micros( | |
| ) * 1_000_000 + timedelta.microseconds | ||
|
|
||
| raise TypeError(f"Unrecognized input type: {type(timedelta)}") | ||
|
|
||
|
|
||
| def get_ipython_execution_count() -> typing.Optional[int]: | ||
| """Returns the current IPython cell execution count if running in a notebook, else None.""" | ||
| try: | ||
| import IPython | ||
|
|
||
| ipy = IPython.get_ipython() | ||
| if ipy is not None and hasattr(ipy, "execution_count"): | ||
| return ipy.execution_count | ||
|
Contributor
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. Don't rely on monkey patching, may be consider some existing settings or properties. |
||
| except (ImportError, NameError): | ||
| pass | ||
| return None | ||
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.
Is it job count? Please be explicit.