Skip to content

fix(bigframes): resolve session-scoped API method logging - #18076

Merged
shuoweil merged 6 commits into
mainfrom
shuowei-fix-session-logging-and-labels
Aug 12, 2026
Merged

fix(bigframes): resolve session-scoped API method logging#18076
shuoweil merged 6 commits into
mainfrom
shuowei-fix-session-logging-and-labels

Conversation

@shuoweil

@shuoweil shuoweil commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Fixes an issue where API method calls on DataFrame and Series objects were recorded into global state instead of their specific session, preventing cross-session and cross-test logging interference.

  • Updated log_adapter._find_session to detect active sessions directly from DataFrame and Series instances.
  • Added recursion safeguards during session property lookup in log_adapter.

Fixes #<545233537> 🦕

@shuoweil
shuoweil requested review from sycai and tswast August 11, 2026 19:29
@shuoweil shuoweil self-assigned this Aug 11, 2026
@shuoweil
shuoweil requested review from a team as code owners August 11, 2026 19:29

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the session resolution logic in log_adapter.py to search through all positional arguments for a Session instance or objects containing a _session or session attribute. It also updates the unit tests in test_io_bigquery.py to use explicit mock sessions and log adapter calls instead of relying on DataFrame operations. The review feedback suggests refactoring the session attribute lookup in _find_session to eliminate duplicated code by iterating over a tuple of attribute names.

Comment thread packages/bigframes/bigframes/core/logging/log_adapter.py Outdated
@shuoweil
shuoweil force-pushed the shuowei-fix-session-logging-and-labels branch from 0f0d41f to 74e2ba2 Compare August 11, 2026 19:32
@shuoweil
shuoweil marked this pull request as draft August 11, 2026 19:32
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@shuoweil
shuoweil marked this pull request as ready for review August 11, 2026 19:36
@shuoweil shuoweil changed the title fix: resolve session-scoped api logging and stabilize label trimming tests fix: resolve session-scoped API method logging Aug 11, 2026
@daniel-sanche daniel-sanche changed the title fix: resolve session-scoped API method logging fix(bigframes): resolve session-scoped API method logging Aug 11, 2026
Comment on lines +330 to +337
for arg in args:
if isinstance(arg, Session) and _is_session_initialized(arg):
return arg
if hasattr(arg, "__dict__") and "_block" in arg.__dict__:
session = getattr(arg, "_session", None)
if isinstance(session, Session) and _is_session_initialized(session):
return session

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be place this before the kwargs check to preserve the original checking sequence?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Reordered _find_session to check args before kwargs, preserving the original sequence.

@shuoweil
shuoweil enabled auto-merge (squash) August 11, 2026 22:31
@shuoweil shuoweil added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 11, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 11, 2026
@shuoweil shuoweil added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 12, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 12, 2026
@shuoweil
shuoweil merged commit ace618b into main Aug 12, 2026
52 checks passed
@shuoweil
shuoweil deleted the shuowei-fix-session-logging-and-labels branch August 12, 2026 15:19
shuoweil pushed a commit that referenced this pull request Aug 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.48.0](bigframes-v2.47.0...bigframes-v2.48.0)
(2026-08-12)


### Features

* **bigframes:** Transpiler supports more string ops
([#17693](#17693))
([7d2bc21](7d2bc21))


### Bug Fixes

* **bigframes:** fix field name typos for ai.generate* functions
([#17983](#17983))
([1b5c48b](1b5c48b))
* **bigframes:** resolve session-scoped API method logging
([#18076](#18076))
([ace618b](ace618b))
* **bigframes:** update GeminiTextGenerator default model to
gemini-2.5-flash
([#18060](#18060))
([5770ff6](5770ff6))
* bump @angular/compiler, @angular/common, @angular/core,
@angular/forms, @angular/platform-browser, @angular/router and
@angular/compiler-cli in
/packages/bigframes/bigframes/display/table_widget_angular
([#17992](#17992))
([346aaab](346aaab))
* bump fast-uri from 3.1.4 to 3.1.5 in
/packages/bigframes/bigframes/display/table_widget_angular
([#17989](#17989))
([3b3f3f4](3b3f3f4))
* bump hono from 4.12.31 to 4.13.1 in
/packages/bigframes/bigframes/display/table_widget_angular
([#18032](#18032))
([cddf35b](cddf35b))
* bump ip-address and express-rate-limit in
/packages/bigframes/bigframes/display/table_widget_angular
([#17985](#17985))
([02ed656](02ed656))
* bump undici and @angular/build in
/packages/bigframes/bigframes/display/table_widget_angular
([#17986](#17986))
([6938061](6938061))
* bump undici from 7.25.0 to 7.29.0 in /packages/bigframes/tests/js
([#17987](#17987))
([65a3571](65a3571))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
copybara-service Bot pushed a commit to google/bigframes that referenced this pull request Aug 12, 2026
🤖 I have created a release *beep* *boop*
---

##
[2.48.0](googleapis/google-cloud-python@bigframes-v2.47.0...bigframes-v2.48.0)
(2026-08-12)

### Features

* **bigframes:** Transpiler supports more string ops
([#17693](googleapis/google-cloud-python#17693))
([7d2bc21](googleapis/google-cloud-python@7d2bc21))

### Bug Fixes

* **bigframes:** fix field name typos for ai.generate* functions
([#17983](googleapis/google-cloud-python#17983))
([1b5c48b](googleapis/google-cloud-python@1b5c48b))
* **bigframes:** resolve session-scoped API method logging
([#18076](googleapis/google-cloud-python#18076))
([ace618b](googleapis/google-cloud-python@ace618b))
* **bigframes:** update GeminiTextGenerator default model to
gemini-2.5-flash
([#18060](googleapis/google-cloud-python#18060))
([5770ff6](googleapis/google-cloud-python@5770ff6))
* bump @angular/compiler, @angular/common, @angular/core,
@angular/forms, @angular/platform-browser, @angular/router and
@angular/compiler-cli in
/packages/bigframes/bigframes/display/table_widget_angular
([#17992](googleapis/google-cloud-python#17992))
([346aaab](googleapis/google-cloud-python@346aaab))
* bump fast-uri from 3.1.4 to 3.1.5 in
/packages/bigframes/bigframes/display/table_widget_angular
([#17989](googleapis/google-cloud-python#17989))
([3b3f3f4](googleapis/google-cloud-python@3b3f3f4))
* bump hono from 4.12.31 to 4.13.1 in
/packages/bigframes/bigframes/display/table_widget_angular
([#18032](googleapis/google-cloud-python#18032))
([cddf35b](googleapis/google-cloud-python@cddf35b))
* bump ip-address and express-rate-limit in
/packages/bigframes/bigframes/display/table_widget_angular
([#17985](googleapis/google-cloud-python#17985))
([02ed656](googleapis/google-cloud-python@02ed656))
* bump undici and @angular/build in
/packages/bigframes/bigframes/display/table_widget_angular
([#17986](googleapis/google-cloud-python#17986))
([6938061](googleapis/google-cloud-python@6938061))
* bump undici from 7.25.0 to 7.29.0 in /packages/bigframes/tests/js
([#17987](googleapis/google-cloud-python#17987))
([65a3571](googleapis/google-cloud-python@65a3571))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
GitOrigin-RevId: 102c940183ac1cf5670b46c17a47f559926634de
Change-Id: Ia15429511df3ebed77f5b4ad45779f8c6be0316d
hebaalazzeh pushed a commit that referenced this pull request Aug 13, 2026
Fixes an issue where API method calls on DataFrame and Series objects
were recorded into global state instead of their specific session,
preventing cross-session and cross-test logging interference.

- Updated `log_adapter._find_session` to detect active sessions directly
from DataFrame and Series instances.
- Added recursion safeguards during session property lookup in
`log_adapter`.


Fixes #<545233537> 🦕

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
hebaalazzeh pushed a commit that referenced this pull request Aug 13, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.48.0](bigframes-v2.47.0...bigframes-v2.48.0)
(2026-08-12)


### Features

* **bigframes:** Transpiler supports more string ops
([#17693](#17693))
([7d2bc21](7d2bc21))


### Bug Fixes

* **bigframes:** fix field name typos for ai.generate* functions
([#17983](#17983))
([1b5c48b](1b5c48b))
* **bigframes:** resolve session-scoped API method logging
([#18076](#18076))
([ace618b](ace618b))
* **bigframes:** update GeminiTextGenerator default model to
gemini-2.5-flash
([#18060](#18060))
([5770ff6](5770ff6))
* bump @angular/compiler, @angular/common, @angular/core,
@angular/forms, @angular/platform-browser, @angular/router and
@angular/compiler-cli in
/packages/bigframes/bigframes/display/table_widget_angular
([#17992](#17992))
([346aaab](346aaab))
* bump fast-uri from 3.1.4 to 3.1.5 in
/packages/bigframes/bigframes/display/table_widget_angular
([#17989](#17989))
([3b3f3f4](3b3f3f4))
* bump hono from 4.12.31 to 4.13.1 in
/packages/bigframes/bigframes/display/table_widget_angular
([#18032](#18032))
([cddf35b](cddf35b))
* bump ip-address and express-rate-limit in
/packages/bigframes/bigframes/display/table_widget_angular
([#17985](#17985))
([02ed656](02ed656))
* bump undici and @angular/build in
/packages/bigframes/bigframes/display/table_widget_angular
([#17986](#17986))
([6938061](6938061))
* bump undici from 7.25.0 to 7.29.0 in /packages/bigframes/tests/js
([#17987](#17987))
([65a3571](65a3571))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants