Skip to content

feat(bigtable): pass user agent, tests and start timeout env variable - #18686

Merged
mutianf merged 6 commits into
bigtable-accelfrom
accel6
Oct 21, 2026
Merged

mutianf merged 6 commits into
bigtable-accelfrom
accel6

Conversation

@mutianf

@mutianf mutianf commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
  • Pass Python client version to user agent.
  • add a start timeout env variable.
  • add tests.

Stack created with GitHub Stacks CLI • Give Feedback 💬

@mutianf
mutianf requested a review from a team as a code owner October 13, 2026 19:56
@mutianf
mutianf added this pull request to stack #18689 October 13, 2026 19:56

@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 adds a --caller-user-agent flag containing the Python client version to the accelerator flags in both the async and sync Bigtable data clients, along with corresponding unit tests. The feedback recommends importing google.cloud.bigtable locally within the configuration method to avoid potential circular imports, NameError, or AttributeError issues.

Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_async/client.py Outdated
@mutianf
mutianf requested a review from sushanb October 13, 2026 19:57
@mutianf
mutianf removed this pull request from stack #18689 October 13, 2026 20:06
@mutianf
mutianf added this pull request to stack #18691 October 13, 2026 20:07
@mutianf mutianf changed the title feat(bigtable): pass Python client version to accelerator daemon for User-Agent prefixing feat(bigtable): pass user agent, tests and start timeout env variable Oct 13, 2026
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_async/client.py Outdated
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_sync_autogen/client.py Outdated
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_async/client.py Outdated
Comment thread packages/google-cloud-bigtable/tests/unit/data/test_accelerator_daemon.py Outdated
mutianf added a commit that referenced this pull request Oct 14, 2026
- Remove _AcceleratorUnverified alias (no longer needed)
- Remove duplicate User-Agent flags block from _init_accelerator_config; keep only the early block so the flag is forwarded even when the daemon is blocked
- Move _AcceleratorIdentityError handling into _start_accelerator: close daemon, warn 'could not verify daemon identity', return without re-raising
- Remove test_binary_path_param_bypasses_lookup (binary_path is a test-only knob already exercised implicitly)
- Add test_close_clears_all_state to verify _proc/_tempdir/_uds_path/_log_path/_auth_secret are all None after close()
- Add --app-profile to TestCliFlags.test_cli_flags_appended_to_argv
- Add assert not t._accelerator_breaker.bypass() to test_non_grpc_exception_reraises in both TestMutateRowViaAccelerator and TestReadRowViaAccelerator

Change-Id: Iff4489acc63a6e71211939c23db04ff1a5df10ba
mutianf added a commit that referenced this pull request Oct 14, 2026
- Remove _AcceleratorUnverified alias (no longer needed)
- Remove duplicate User-Agent flags block from _init_accelerator_config; keep only the early block so the flag is forwarded even when the daemon is blocked
- Add local import google.cloud.bigtable inside _init_accelerator_config to avoid potential circular import at module level
- Move _AcceleratorIdentityError handling into _start_accelerator: close daemon, warn 'could not verify daemon identity', return without re-raising
- Remove test_binary_path_param_bypasses_lookup (binary_path is a test-only knob already exercised implicitly)
- Add --app-profile to TestCliFlags.test_cli_flags_appended_to_argv
- Add assert not t._accelerator_breaker.bypass() to test_non_grpc_exception_reraises in both TestMutateRowViaAccelerator and TestReadRowViaAccelerator

Change-Id: I43b354ad6517a2c0b9f6a2294cdd2d1639d7fe8c
mutianf added a commit that referenced this pull request Oct 14, 2026
- Remove _AcceleratorUnverified alias (no longer needed)
- Remove duplicate User-Agent flags block from _init_accelerator_config; keep only the early block so the flag is forwarded even when the daemon is blocked
- Move _AcceleratorIdentityError handling into _start_accelerator: close daemon, warn 'could not verify daemon identity', return without re-raising
- Remove test_binary_path_param_bypasses_lookup (binary_path is a test-only knob already exercised implicitly)
- Add test_close_clears_all_state to verify _proc/_tempdir/_uds_path/_log_path/_auth_secret are all None after close()
- Add --app-profile to TestCliFlags.test_cli_flags_appended_to_argv
- Add assert not t._accelerator_breaker.bypass() to test_non_grpc_exception_reraises in both TestMutateRowViaAccelerator and TestReadRowViaAccelerator

Change-Id: Iff4489acc63a6e71211939c23db04ff1a5df10ba

review(bigtable): address PR #18686 reviewer comments

- Remove _AcceleratorUnverified alias (no longer needed)
- Remove duplicate User-Agent flags block from _init_accelerator_config; keep only the early block so the flag is forwarded even when the daemon is blocked
- Add local import google.cloud.bigtable inside _init_accelerator_config to avoid potential circular import at module level
- Move _AcceleratorIdentityError handling into _start_accelerator: close daemon, warn 'could not verify daemon identity', return without re-raising
- Remove test_binary_path_param_bypasses_lookup (binary_path is a test-only knob already exercised implicitly)
- Add --app-profile to TestCliFlags.test_cli_flags_appended_to_argv
- Add assert not t._accelerator_breaker.bypass() to test_non_grpc_exception_reraises in both TestMutateRowViaAccelerator and TestReadRowViaAccelerator

Change-Id: I43b354ad6517a2c0b9f6a2294cdd2d1639d7fe8c

test(bigtable): add TestCleanupTempdir to verify _cleanup_tempdir clears all state

Change-Id: I6d6ec51cc039c78d884451502b368862fe8d4ae3
Base automatically changed from accel5 to bigtable-accel October 21, 2026 16:52
…User-Agent prefixing

Pass --caller-user-agent python-v<version> when spawning the daemon so it
can construct the full User-Agent prefix (e.g. python-v3.0.0a0-go-accelerator-v3.x.x)
for accurate audit logging and traffic attribution.

Change-Id: I621217335ad54377a84d44ab4b9af88770dd2958
- Remove _AcceleratorUnverified alias (no longer needed)
- Remove duplicate User-Agent flags block from _init_accelerator_config; keep only the early block so the flag is forwarded even when the daemon is blocked
- Move _AcceleratorIdentityError handling into _start_accelerator: close daemon, warn 'could not verify daemon identity', return without re-raising
- Remove test_binary_path_param_bypasses_lookup (binary_path is a test-only knob already exercised implicitly)
- Add test_close_clears_all_state to verify _proc/_tempdir/_uds_path/_log_path/_auth_secret are all None after close()
- Add --app-profile to TestCliFlags.test_cli_flags_appended_to_argv
- Add assert not t._accelerator_breaker.bypass() to test_non_grpc_exception_reraises in both TestMutateRowViaAccelerator and TestReadRowViaAccelerator

Change-Id: Iff4489acc63a6e71211939c23db04ff1a5df10ba

review(bigtable): address PR #18686 reviewer comments

- Remove _AcceleratorUnverified alias (no longer needed)
- Remove duplicate User-Agent flags block from _init_accelerator_config; keep only the early block so the flag is forwarded even when the daemon is blocked
- Add local import google.cloud.bigtable inside _init_accelerator_config to avoid potential circular import at module level
- Move _AcceleratorIdentityError handling into _start_accelerator: close daemon, warn 'could not verify daemon identity', return without re-raising
- Remove test_binary_path_param_bypasses_lookup (binary_path is a test-only knob already exercised implicitly)
- Add --app-profile to TestCliFlags.test_cli_flags_appended_to_argv
- Add assert not t._accelerator_breaker.bypass() to test_non_grpc_exception_reraises in both TestMutateRowViaAccelerator and TestReadRowViaAccelerator

Change-Id: I43b354ad6517a2c0b9f6a2294cdd2d1639d7fe8c

test(bigtable): add TestCleanupTempdir to verify _cleanup_tempdir clears all state

Change-Id: I6d6ec51cc039c78d884451502b368862fe8d4ae3
…e auth session

Change-Id: I78f226004fdffe98d83f7d24b04557a24e9fc7a7
…o prevent orphaned daemon on BaseException

Change-Id: I6f4c18f5b03da26efa9b70ed8c6b4d20f9d4a8df
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_accelerator/_daemon.py Outdated
Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_async/client.py Outdated
Comment on lines 346 to 349
self._accelerator_env["GOOGLE_APPLICATION_CREDENTIALS"] = (
credentials_file
)

def _resolve_principal(self) -> str | None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing blank line between the end of _init_accelerator_config and def _resolve_principal — PEP 8 / black / flake8 (E301) want one. Looks like a CrossSync regen artifact; adding the blank line in the async source and re-running the generator should restore it in the sync file.

Suggested change
self._accelerator_env["GOOGLE_APPLICATION_CREDENTIALS"] = (
credentials_file
)
def _resolve_principal(self) -> str | None:
self._accelerator_env["GOOGLE_APPLICATION_CREDENTIALS"] = (
credentials_file
)
def _resolve_principal(self) -> str | None:

Comment thread packages/google-cloud-bigtable/google/cloud/bigtable/data/_accelerator/_daemon.py Outdated
Comment on lines +425 to +430
import google.cloud.bigtable # local import avoids circular dependency

self._accelerator_flags += [
"--caller-user-agent",
f"python-v{google.cloud.bigtable.__version__}",
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pulling in the entire google.cloud.bigtable package on every Table init is overkill when all we want is the version string. Switch to importlib.metadata (stdlib since 3.8), which avoids the circular-dep motivation entirely:

Suggested change
import google.cloud.bigtable # local import avoids circular dependency
self._accelerator_flags += [
"--caller-user-agent",
f"python-v{google.cloud.bigtable.__version__}",
]
from importlib.metadata import version as _pkg_version
self._accelerator_flags += [
"--caller-user-agent",
f"python-v{_pkg_version('google-cloud-bigtable')}",
]

(Can be hoisted to a module-level import if you'd rather; local keeps it self-contained with the use site.)

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.

removed the import line. I think this is already imported.

…n accelerator blocked, regenerate sync client

Change-Id: Ia71d293208e7340bf9cab5cfa9f7e81ce7bb20b5

@sushanb sushanb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM with the inline suggestions above (docstring, user-agent placement, blank-line regen, inf/nan guard, importlib.metadata). None are blockers; happy to see them land as follow-ups or folded in before merge.

@mutianf
mutianf merged commit 5f439b9 into bigtable-accel Oct 21, 2026
16 checks passed
@mutianf
mutianf deleted the accel6 branch October 21, 2026 19:40
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.

2 participants