Repository navigation
Conversation
… -v google-cloud-pubsub
… -v google-cloud-spanner
There was a problem hiding this comment.
Code Review
This pull request updates the generated client libraries for Google Ads AdManager and other services to support OpenTelemetry tracing and client options propagation across all transports. It introduces fallback mechanisms in _compat.py to maintain backward compatibility with older google-api-core versions. The review feedback suggests simplifying the REST transport implementations by replacing defensive getattr(self, '_client_options', None) checks with direct attribute access, since _client_options is guaranteed to be initialized.
…abase Prevent is_otel_capabilities_enabled() from reading a truthy MagicMock for client_options.tracer_provider and raising FeatureGatingError when SpannerClient is instantiated in test_spanner_api_experimental_host
…ead_client_v1 - Bind to the autospecced fixture before calling so RPC methods (, , etc.) are wrapped with real retry callables rather than returning a child . - Set on to prevent from reading a truthy for and raising . This change is necessary following #18433
| database._instance._client._ca_certificate = None | ||
| database._instance._client._client_certificate = None | ||
| database._instance._client._client_key = None | ||
| database._instance._client._client_options = None |
There was a problem hiding this comment.
@parthea For the Spanner test fix, can we initialize self._client_options as a real ClientOptions object inside _Client.__init__ instead of setting _client_options = None in test_spanner_api_experimental_host?
Why ClientOptions seems like a better idea here:
- No truthy/mock surprises: With an unspec'ed
Mock, reading any unset attribute (liketracer_provideror futureClientOptionsfields) returns a truthy childMockinstead ofNone. A realClientOptionsobject naturally defaults unset fields toNone. - Avoids shared-state mutation:
_Instance.__init__uses a shared defaultclient=_Client()across tests, so settingdatabase._instance._client._client_options = Nonein one test mutates_client_optionsfor subsequent tests. - Less boilerplate: It replaces 9 lines of manual
Noneassignments and matchesself._client_info = gapic_v1.client_info.ClientInfo()right above it.
Files and Lines to Update
1. packages/google-cloud-spanner/tests/unit/_async/test_database.py
- Line 2643 (
test_spanner_api_experimental_host): Removedatabase._instance._client._client_options = None. - Lines 4292–4309 (
_Client.__init__): Replace theCrossSync.Mock()setup withClientOptions:
from google.api_core.client_options import ClientOptions
from google.cloud.spanner_v1 import ExecuteSqlRequest
self.project = project
self.project_name = "projects/" + self.project
self._endpoint_cache = {}
self.database_admin_api = _make_database_admin_api()
self.instance_admin_api = _make_instance_api()
self._client_info = gapic_v1.client_info.ClientInfo()
self._client_options = ClientOptions(
api_endpoint="spanner.googleapis.com",
universe_domain="googleapis.com",
)
self._experimental_host = None2. packages/google-cloud-spanner/tests/unit/test_database.py
- Lines 3713–3730 (
_Client.__init__): Apply the same change to the sync helper:
from google.api_core.client_options import ClientOptions
from google.cloud.spanner_v1 import ExecuteSqlRequest
self.project = project
self.project_name = "projects/" + self.project
self._endpoint_cache = {}
self.database_admin_api = _make_database_admin_api()
self.instance_admin_api = _make_instance_api()
self._client_info = gapic_v1.client_info.ClientInfo()
self._client_options = ClientOptions(
api_endpoint="spanner.googleapis.com",
universe_domain="googleapis.com",
)
self._experimental_host = None|
Superseded by #18955 |
Commits 0f79eac and 65710a7 contain manual changes to the post-processing files.
Commits 6470ec4, 7f47443 and 8296956 are the result after running client library generation using
gapic-generatorat commit eb8a766.The following commands were used to re-generate the libraries
53681f8 is needed to resolve the failure in https://github.com/googleapis/google-cloud-python/actions/runs/40380490833/job/121775466746
d8d9616 is needed to resolve the failure in https://github.com/googleapis/google-cloud-python/actions/runs/40386982731/job/121799063007
Towards b/577038296