Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit ffbd3c9

Browse files
chore: use gapic-generator-python 0.62.1 (#71)
- [ ] Regenerate this pull request now. fix: resolve DuplicateCredentialArgs error when using credentials_file committer: parthea PiperOrigin-RevId: 425964861 Source-Link: googleapis/googleapis@84b1a5a Source-Link: https://github.com/googleapis/googleapis-gen/commit/4fb761bbd8506ac156f49bac5f18306aa8eb3aa8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGZiNzYxYmJkODUwNmFjMTU2ZjQ5YmFjNWYxODMwNmFhOGViM2FhOCJ9
1 parent 4230050 commit ffbd3c9

4 files changed

Lines changed: 88 additions & 12 deletions

File tree

google/cloud/lifesciences_v2beta/services/workflows_service_v2_beta/transports/grpc.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,11 @@ def __init__(
162162
if not self._grpc_channel:
163163
self._grpc_channel = type(self).create_channel(
164164
self._host,
165+
# use the credentials which are saved
165166
credentials=self._credentials,
166-
credentials_file=credentials_file,
167+
# Set ``credentials_file`` to ``None`` here as
168+
# the credentials that we saved earlier should be used.
169+
credentials_file=None,
167170
scopes=self._scopes,
168171
ssl_credentials=self._ssl_channel_credentials,
169172
quota_project_id=quota_project_id,
@@ -236,7 +239,7 @@ def operations_client(self) -> operations_v1.OperationsClient:
236239
This property caches on the instance; repeated calls return the same
237240
client.
238241
"""
239-
# Sanity check: Only create a new client if we do not already have one.
242+
# Quick check: Only create a new client if we do not already have one.
240243
if self._operations_client is None:
241244
self._operations_client = operations_v1.OperationsClient(self.grpc_channel)
242245

google/cloud/lifesciences_v2beta/services/workflows_service_v2_beta/transports/grpc_asyncio.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,11 @@ def __init__(
207207
if not self._grpc_channel:
208208
self._grpc_channel = type(self).create_channel(
209209
self._host,
210+
# use the credentials which are saved
210211
credentials=self._credentials,
211-
credentials_file=credentials_file,
212+
# Set ``credentials_file`` to ``None`` here as
213+
# the credentials that we saved earlier should be used.
214+
credentials_file=None,
212215
scopes=self._scopes,
213216
ssl_credentials=self._ssl_channel_credentials,
214217
quota_project_id=quota_project_id,
@@ -238,7 +241,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient:
238241
This property caches on the instance; repeated calls return the same
239242
client.
240243
"""
241-
# Sanity check: Only create a new client if we do not already have one.
244+
# Quick check: Only create a new client if we do not already have one.
242245
if self._operations_client is None:
243246
self._operations_client = operations_v1.OperationsAsyncClient(
244247
self.grpc_channel

google/cloud/lifesciences_v2beta/types/workflows.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,7 @@ class VirtualMachine(proto.Message):
437437
a significant impact.
438438
For more information about the effect of this
439439
parameter, see
440-
https://cloud.google.com/compute/docs/instances/specify-
441-
min-cpu-platform.
440+
https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform.
442441
boot_image (str):
443442
The host operating system image to use.
444443
@@ -512,8 +511,8 @@ class ServiceAccount(proto.Message):
512511
account for the project will be used.
513512
scopes (Sequence[str]):
514513
List of scopes to be enabled for this service
515-
account on the VM, in addition to the cloud-
516-
platform API scope that will be added by
514+
account on the VM, in addition to the
515+
cloud-platform API scope that will be added by
517516
default.
518517
"""
519518

@@ -562,8 +561,9 @@ class Network(proto.Message):
562561
address, additional configuration is required to
563562
allow the VM to access Google services.
564563
565-
See https://cloud.google.com/vpc/docs/configure-
566-
private-google-access for more information.
564+
See
565+
https://cloud.google.com/vpc/docs/configure-private-google-access
566+
for more information.
567567
subnetwork (str):
568568
If the specified network is configured for custom subnet
569569
creation, the name of the subnetwork to attach the instance

tests/unit/gapic/lifesciences_v2beta/test_workflows_service_v2_beta.py

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from google.api_core import gapic_v1
3030
from google.api_core import grpc_helpers
3131
from google.api_core import grpc_helpers_async
32+
from google.api_core import operation
3233
from google.api_core import operation_async # type: ignore
3334
from google.api_core import operations_v1
3435
from google.api_core import path_template
@@ -539,25 +540,28 @@ def test_workflows_service_v2_beta_client_client_options_scopes(
539540

540541

541542
@pytest.mark.parametrize(
542-
"client_class,transport_class,transport_name",
543+
"client_class,transport_class,transport_name,grpc_helpers",
543544
[
544545
(
545546
WorkflowsServiceV2BetaClient,
546547
transports.WorkflowsServiceV2BetaGrpcTransport,
547548
"grpc",
549+
grpc_helpers,
548550
),
549551
(
550552
WorkflowsServiceV2BetaAsyncClient,
551553
transports.WorkflowsServiceV2BetaGrpcAsyncIOTransport,
552554
"grpc_asyncio",
555+
grpc_helpers_async,
553556
),
554557
],
555558
)
556559
def test_workflows_service_v2_beta_client_client_options_credentials_file(
557-
client_class, transport_class, transport_name
560+
client_class, transport_class, transport_name, grpc_helpers
558561
):
559562
# Check the case credentials file is provided.
560563
options = client_options.ClientOptions(credentials_file="credentials.json")
564+
561565
with mock.patch.object(transport_class, "__init__") as patched:
562566
patched.return_value = None
563567
client = client_class(client_options=options, transport=transport_name)
@@ -593,6 +597,72 @@ def test_workflows_service_v2_beta_client_client_options_from_dict():
593597
)
594598

595599

600+
@pytest.mark.parametrize(
601+
"client_class,transport_class,transport_name,grpc_helpers",
602+
[
603+
(
604+
WorkflowsServiceV2BetaClient,
605+
transports.WorkflowsServiceV2BetaGrpcTransport,
606+
"grpc",
607+
grpc_helpers,
608+
),
609+
(
610+
WorkflowsServiceV2BetaAsyncClient,
611+
transports.WorkflowsServiceV2BetaGrpcAsyncIOTransport,
612+
"grpc_asyncio",
613+
grpc_helpers_async,
614+
),
615+
],
616+
)
617+
def test_workflows_service_v2_beta_client_create_channel_credentials_file(
618+
client_class, transport_class, transport_name, grpc_helpers
619+
):
620+
# Check the case credentials file is provided.
621+
options = client_options.ClientOptions(credentials_file="credentials.json")
622+
623+
with mock.patch.object(transport_class, "__init__") as patched:
624+
patched.return_value = None
625+
client = client_class(client_options=options, transport=transport_name)
626+
patched.assert_called_once_with(
627+
credentials=None,
628+
credentials_file="credentials.json",
629+
host=client.DEFAULT_ENDPOINT,
630+
scopes=None,
631+
client_cert_source_for_mtls=None,
632+
quota_project_id=None,
633+
client_info=transports.base.DEFAULT_CLIENT_INFO,
634+
always_use_jwt_access=True,
635+
)
636+
637+
# test that the credentials from file are saved and used as the credentials.
638+
with mock.patch.object(
639+
google.auth, "load_credentials_from_file", autospec=True
640+
) as load_creds, mock.patch.object(
641+
google.auth, "default", autospec=True
642+
) as adc, mock.patch.object(
643+
grpc_helpers, "create_channel"
644+
) as create_channel:
645+
creds = ga_credentials.AnonymousCredentials()
646+
file_creds = ga_credentials.AnonymousCredentials()
647+
load_creds.return_value = (file_creds, None)
648+
adc.return_value = (creds, None)
649+
client = client_class(client_options=options, transport=transport_name)
650+
create_channel.assert_called_with(
651+
"lifesciences.googleapis.com:443",
652+
credentials=file_creds,
653+
credentials_file=None,
654+
quota_project_id=None,
655+
default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
656+
scopes=None,
657+
default_host="lifesciences.googleapis.com",
658+
ssl_credentials=None,
659+
options=[
660+
("grpc.max_send_message_length", -1),
661+
("grpc.max_receive_message_length", -1),
662+
],
663+
)
664+
665+
596666
@pytest.mark.parametrize("request_type", [workflows.RunPipelineRequest, dict,])
597667
def test_run_pipeline(request_type, transport: str = "grpc"):
598668
client = WorkflowsServiceV2BetaClient(

0 commit comments

Comments
 (0)