fix(bigframes): resolve session-scoped API method logging - #18076
fix(bigframes): resolve session-scoped API method logging#18076shuoweil wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
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.
0f0d41f to
74e2ba2
Compare
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
| 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 | ||
|
|
There was a problem hiding this comment.
Should be place this before the kwargs check to preserve the original checking sequence?
There was a problem hiding this comment.
Good point! Reordered _find_session to check args before kwargs, preserving the original sequence.
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.
log_adapter._find_sessionto detect active sessions directly from DataFrame and Series instances.log_adapter.Fixes #<545233537> 🦕