Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@gkevinzheng
Copy link
Contributor

This PR implements both the async client's wait_for_consistency and __init__ methods, as well as the async polling harness class.

@gkevinzheng gkevinzheng requested review from a team as code owners June 23, 2025 21:00
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: bigtable Issues related to the googleapis/python-bigtable API. labels Jun 23, 2025

This should not be used by the user to wait until the `check_consistency` call finishes;
use the :meth:`result <google.api_core.future.async_future.AsyncFuture.result>` method of
this class instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be used by the user to wait until the check_consistency call finishes;
use the :meth:result <google.api_core.future.async_future.AsyncFuture.result> method of
this class instead.

Is this something you added? Whay happens if the user uses this directly?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still wondering about this. It doesn't matter so much if this is internal, but I'm wondering why it needs this warning

Copy link
Contributor Author

@gkevinzheng gkevinzheng Jun 30, 2025

Choose a reason for hiding this comment

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

Ahh yeah, this is from when it wasn't internal. I think I can delete this part of the docstring now because the underscore prefix should convey this, and the fact that they're not going to use this directly.

I think my justification for this is that from the documentation perspective, it looks like done should do something for the user, and it does, but it's for the loop of using result, which indirectly calls done.

# Wait for the table to become consistent
print("Waiting for operation to complete...")

response = future.result()
Copy link
Contributor

Choose a reason for hiding this comment

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

this needs an await. And the sample needs an async

retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> async_consistency.AsyncCheckConsistencyPollingFuture:
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we want to return this custom Future directly. We could encapsulate it and use pure asyncio-native coroutines instead

That would be more idiomatic, but wouldn't be as consistent between sync/async. Do you think users will do anything with this future other than call .result()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They could call add_done_callback but that's not documented too well. Should we do the awaiting, aka poll the call in the function instead of returning the polling harness to the user?

try:
OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object, None] # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be AsyncRetry for the async client

transport=transport,
client_options=client_options,
client_info=client_info,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this doing anything different than the base client?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only thing it's doing differently is using a different default option for the client_info parameter (see lines 61-62), to provide a different version in DEFAULT_CLIENT_INFO


This should not be used by the user to wait until the `check_consistency` call finishes;
use the :meth:`result <google.api_core.future.async_future.AsyncFuture.result>` method of
this class instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still wondering about this. It doesn't matter so much if this is internal, but I'm wondering why it needs this warning

@gkevinzheng gkevinzheng added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 2, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 2, 2025
@gkevinzheng gkevinzheng merged commit 71c3000 into autogen-feature-branch Jul 11, 2025
7 of 10 checks passed
@gkevinzheng gkevinzheng deleted the async-client-admin branch July 11, 2025 17:41
gkevinzheng added a commit that referenced this pull request Aug 1, 2025
…ration (#1177)

* chore: Removed old admin_v2 GAPIC layer (#1111)

* feat!: Generated Selective GAPIC layer for Admin API (#1112)

* chore: Updated service YAML by making all methods in BigtableInstanceAdmin public (#1113)

* refactor: Refactored classic client to use new Admin API (#1114)

* refactor: Refactored classic client to use new Admin API

* added newline after gapic_version files

* fix: Made generate_consistency_token and check_consistency public (#1116)

methods

* feat: Consistency polling + restore table for sync client in admin (#1117)

* feat: Prototyped handwritten layer

* Added newlines

* linting

* Added docstrings for restore table and consistency token polling;
removed gc_rule

* docs: owlbot related changes (#1133)

* docs: owlbot related changes

* Addressed PR feedback + made changes to toc.yml for docs pipeline

* Fixed type hint

* linting + added validation for admin section

* linting + added noqas to owlbot lines

* tests: Tests for sync client + fixes + client library versioning (#1132)

* tests: Tests for sync client + fixes + client library versioning

* Removed raise exception

* linting + name changes in tests + added test for timeout

* linting

* Fixed tests on Python 3.7

* feat: Proto-plus modifications for enforcing strict oneofs (#1126)

* feat: Proto-plus modifications for enforcing strict oneofs

* Added template directory + changed unit tests to pytest

* Finished README

* linting

* Added source of truth comment

* feat: Reworked the wait_for_consistency call (#1144)

* feat: Reworked the wait_for_consistency call

* linting

* Update google/cloud/bigtable/admin_v2/overlay/services/bigtable_table_admin/client.py

Co-authored-by: Mattie Fu <[email protected]>

* Improved documentation

* linting again

* linting

---------

Co-authored-by: Mattie Fu <[email protected]>

* feat: Async consistency polling harness (#1142)

* feat: Async consistency polling harness

* Fixed AsyncMock issue in Python 3.7

* Reworked async_consistency and added async client to __init__.py

* linting

* addressed review feedback

* linting

* feat: Restore Table LRO rework + async restore table (#1148)

* chore(tests): system tests for autogen API (#1151)

* tests: system tests for autogen API

* Fixed async system tests

* addressed review feedback

* Fixed system test failure at the end of a test run

* Linting

* more linting

* chore: Moved Admin API from google.cloud.bigtable.admin_v2 back to google.cloud.bigtable_admin_v2 (#1153)

* chore: Removed autogenerated files from the feature branch (#1170)

* chore: Merged selective GAPIC autogenerated changes into feature branch (#1175)

* chore: Merged selective GAPIC owlbot changes into feature branch

* linting

* changed comment text

* Removed redundant items

* Fixed owlbot infinitely appending text

* Added comments + fixed indentation in Owlbot

* Added anonymous credentials to client tests

* Fixed project ID issue in system tests

* Fixed docstrings and skipped system tests on emulator.

---------

Co-authored-by: Mattie Fu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigtable Issues related to the googleapis/python-bigtable API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants