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

Commit 3e7c964

Browse files
chore: use gapic-generator-python 0.62.1 (#260)
- [ ] 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 Closes #259
1 parent 593ec8a commit 3e7c964

11 files changed

Lines changed: 198 additions & 35 deletions

File tree

google/cloud/language_v1/services/language_service/async_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ async def analyze_sentiment(
242242
243243
"""
244244
# Create or coerce a protobuf request object.
245-
# Sanity check: If we got a request object, we should *not* have
245+
# Quick check: If we got a request object, we should *not* have
246246
# gotten any keyword arguments that map to the request.
247247
has_flattened_params = any([document, encoding_type])
248248
if request is not None and has_flattened_params:
@@ -325,7 +325,7 @@ async def analyze_entities(
325325
The entity analysis response message.
326326
"""
327327
# Create or coerce a protobuf request object.
328-
# Sanity check: If we got a request object, we should *not* have
328+
# Quick check: If we got a request object, we should *not* have
329329
# gotten any keyword arguments that map to the request.
330330
has_flattened_params = any([document, encoding_type])
331331
if request is not None and has_flattened_params:
@@ -411,7 +411,7 @@ async def analyze_entity_sentiment(
411411
412412
"""
413413
# Create or coerce a protobuf request object.
414-
# Sanity check: If we got a request object, we should *not* have
414+
# Quick check: If we got a request object, we should *not* have
415415
# gotten any keyword arguments that map to the request.
416416
has_flattened_params = any([document, encoding_type])
417417
if request is not None and has_flattened_params:
@@ -493,7 +493,7 @@ async def analyze_syntax(
493493
The syntax analysis response message.
494494
"""
495495
# Create or coerce a protobuf request object.
496-
# Sanity check: If we got a request object, we should *not* have
496+
# Quick check: If we got a request object, we should *not* have
497497
# gotten any keyword arguments that map to the request.
498498
has_flattened_params = any([document, encoding_type])
499499
if request is not None and has_flattened_params:
@@ -568,7 +568,7 @@ async def classify_text(
568568
569569
"""
570570
# Create or coerce a protobuf request object.
571-
# Sanity check: If we got a request object, we should *not* have
571+
# Quick check: If we got a request object, we should *not* have
572572
# gotten any keyword arguments that map to the request.
573573
has_flattened_params = any([document])
574574
if request is not None and has_flattened_params:
@@ -658,7 +658,7 @@ async def annotate_text(
658658
659659
"""
660660
# Create or coerce a protobuf request object.
661-
# Sanity check: If we got a request object, we should *not* have
661+
# Quick check: If we got a request object, we should *not* have
662662
# gotten any keyword arguments that map to the request.
663663
has_flattened_params = any([document, features, encoding_type])
664664
if request is not None and has_flattened_params:

google/cloud/language_v1/services/language_service/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ def analyze_sentiment(
425425
426426
"""
427427
# Create or coerce a protobuf request object.
428-
# Sanity check: If we got a request object, we should *not* have
428+
# Quick check: If we got a request object, we should *not* have
429429
# gotten any keyword arguments that map to the request.
430430
has_flattened_params = any([document, encoding_type])
431431
if request is not None and has_flattened_params:
@@ -498,7 +498,7 @@ def analyze_entities(
498498
The entity analysis response message.
499499
"""
500500
# Create or coerce a protobuf request object.
501-
# Sanity check: If we got a request object, we should *not* have
501+
# Quick check: If we got a request object, we should *not* have
502502
# gotten any keyword arguments that map to the request.
503503
has_flattened_params = any([document, encoding_type])
504504
if request is not None and has_flattened_params:
@@ -574,7 +574,7 @@ def analyze_entity_sentiment(
574574
575575
"""
576576
# Create or coerce a protobuf request object.
577-
# Sanity check: If we got a request object, we should *not* have
577+
# Quick check: If we got a request object, we should *not* have
578578
# gotten any keyword arguments that map to the request.
579579
has_flattened_params = any([document, encoding_type])
580580
if request is not None and has_flattened_params:
@@ -646,7 +646,7 @@ def analyze_syntax(
646646
The syntax analysis response message.
647647
"""
648648
# Create or coerce a protobuf request object.
649-
# Sanity check: If we got a request object, we should *not* have
649+
# Quick check: If we got a request object, we should *not* have
650650
# gotten any keyword arguments that map to the request.
651651
has_flattened_params = any([document, encoding_type])
652652
if request is not None and has_flattened_params:
@@ -711,7 +711,7 @@ def classify_text(
711711
712712
"""
713713
# Create or coerce a protobuf request object.
714-
# Sanity check: If we got a request object, we should *not* have
714+
# Quick check: If we got a request object, we should *not* have
715715
# gotten any keyword arguments that map to the request.
716716
has_flattened_params = any([document])
717717
if request is not None and has_flattened_params:
@@ -791,7 +791,7 @@ def annotate_text(
791791
792792
"""
793793
# Create or coerce a protobuf request object.
794-
# Sanity check: If we got a request object, we should *not* have
794+
# Quick check: If we got a request object, we should *not* have
795795
# gotten any keyword arguments that map to the request.
796796
has_flattened_params = any([document, features, encoding_type])
797797
if request is not None and has_flattened_params:

google/cloud/language_v1/services/language_service/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,11 @@ def __init__(
159159
if not self._grpc_channel:
160160
self._grpc_channel = type(self).create_channel(
161161
self._host,
162+
# use the credentials which are saved
162163
credentials=self._credentials,
163-
credentials_file=credentials_file,
164+
# Set ``credentials_file`` to ``None`` here as
165+
# the credentials that we saved earlier should be used.
166+
credentials_file=None,
164167
scopes=self._scopes,
165168
ssl_credentials=self._ssl_channel_credentials,
166169
quota_project_id=quota_project_id,

google/cloud/language_v1/services/language_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ def __init__(
204204
if not self._grpc_channel:
205205
self._grpc_channel = type(self).create_channel(
206206
self._host,
207+
# use the credentials which are saved
207208
credentials=self._credentials,
208-
credentials_file=credentials_file,
209+
# Set ``credentials_file`` to ``None`` here as
210+
# the credentials that we saved earlier should be used.
211+
credentials_file=None,
209212
scopes=self._scopes,
210213
ssl_credentials=self._ssl_channel_credentials,
211214
quota_project_id=quota_project_id,

google/cloud/language_v1beta2/services/language_service/async_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ async def analyze_sentiment(
243243
244244
"""
245245
# Create or coerce a protobuf request object.
246-
# Sanity check: If we got a request object, we should *not* have
246+
# Quick check: If we got a request object, we should *not* have
247247
# gotten any keyword arguments that map to the request.
248248
has_flattened_params = any([document, encoding_type])
249249
if request is not None and has_flattened_params:
@@ -326,7 +326,7 @@ async def analyze_entities(
326326
The entity analysis response message.
327327
"""
328328
# Create or coerce a protobuf request object.
329-
# Sanity check: If we got a request object, we should *not* have
329+
# Quick check: If we got a request object, we should *not* have
330330
# gotten any keyword arguments that map to the request.
331331
has_flattened_params = any([document, encoding_type])
332332
if request is not None and has_flattened_params:
@@ -412,7 +412,7 @@ async def analyze_entity_sentiment(
412412
413413
"""
414414
# Create or coerce a protobuf request object.
415-
# Sanity check: If we got a request object, we should *not* have
415+
# Quick check: If we got a request object, we should *not* have
416416
# gotten any keyword arguments that map to the request.
417417
has_flattened_params = any([document, encoding_type])
418418
if request is not None and has_flattened_params:
@@ -494,7 +494,7 @@ async def analyze_syntax(
494494
The syntax analysis response message.
495495
"""
496496
# Create or coerce a protobuf request object.
497-
# Sanity check: If we got a request object, we should *not* have
497+
# Quick check: If we got a request object, we should *not* have
498498
# gotten any keyword arguments that map to the request.
499499
has_flattened_params = any([document, encoding_type])
500500
if request is not None and has_flattened_params:
@@ -569,7 +569,7 @@ async def classify_text(
569569
570570
"""
571571
# Create or coerce a protobuf request object.
572-
# Sanity check: If we got a request object, we should *not* have
572+
# Quick check: If we got a request object, we should *not* have
573573
# gotten any keyword arguments that map to the request.
574574
has_flattened_params = any([document])
575575
if request is not None and has_flattened_params:
@@ -659,7 +659,7 @@ async def annotate_text(
659659
660660
"""
661661
# Create or coerce a protobuf request object.
662-
# Sanity check: If we got a request object, we should *not* have
662+
# Quick check: If we got a request object, we should *not* have
663663
# gotten any keyword arguments that map to the request.
664664
has_flattened_params = any([document, features, encoding_type])
665665
if request is not None and has_flattened_params:

google/cloud/language_v1beta2/services/language_service/client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def analyze_sentiment(
426426
427427
"""
428428
# Create or coerce a protobuf request object.
429-
# Sanity check: If we got a request object, we should *not* have
429+
# Quick check: If we got a request object, we should *not* have
430430
# gotten any keyword arguments that map to the request.
431431
has_flattened_params = any([document, encoding_type])
432432
if request is not None and has_flattened_params:
@@ -499,7 +499,7 @@ def analyze_entities(
499499
The entity analysis response message.
500500
"""
501501
# Create or coerce a protobuf request object.
502-
# Sanity check: If we got a request object, we should *not* have
502+
# Quick check: If we got a request object, we should *not* have
503503
# gotten any keyword arguments that map to the request.
504504
has_flattened_params = any([document, encoding_type])
505505
if request is not None and has_flattened_params:
@@ -575,7 +575,7 @@ def analyze_entity_sentiment(
575575
576576
"""
577577
# Create or coerce a protobuf request object.
578-
# Sanity check: If we got a request object, we should *not* have
578+
# Quick check: If we got a request object, we should *not* have
579579
# gotten any keyword arguments that map to the request.
580580
has_flattened_params = any([document, encoding_type])
581581
if request is not None and has_flattened_params:
@@ -647,7 +647,7 @@ def analyze_syntax(
647647
The syntax analysis response message.
648648
"""
649649
# Create or coerce a protobuf request object.
650-
# Sanity check: If we got a request object, we should *not* have
650+
# Quick check: If we got a request object, we should *not* have
651651
# gotten any keyword arguments that map to the request.
652652
has_flattened_params = any([document, encoding_type])
653653
if request is not None and has_flattened_params:
@@ -712,7 +712,7 @@ def classify_text(
712712
713713
"""
714714
# Create or coerce a protobuf request object.
715-
# Sanity check: If we got a request object, we should *not* have
715+
# Quick check: If we got a request object, we should *not* have
716716
# gotten any keyword arguments that map to the request.
717717
has_flattened_params = any([document])
718718
if request is not None and has_flattened_params:
@@ -792,7 +792,7 @@ def annotate_text(
792792
793793
"""
794794
# Create or coerce a protobuf request object.
795-
# Sanity check: If we got a request object, we should *not* have
795+
# Quick check: If we got a request object, we should *not* have
796796
# gotten any keyword arguments that map to the request.
797797
has_flattened_params = any([document, features, encoding_type])
798798
if request is not None and has_flattened_params:

google/cloud/language_v1beta2/services/language_service/transports/grpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,11 @@ def __init__(
159159
if not self._grpc_channel:
160160
self._grpc_channel = type(self).create_channel(
161161
self._host,
162+
# use the credentials which are saved
162163
credentials=self._credentials,
163-
credentials_file=credentials_file,
164+
# Set ``credentials_file`` to ``None`` here as
165+
# the credentials that we saved earlier should be used.
166+
credentials_file=None,
164167
scopes=self._scopes,
165168
ssl_credentials=self._ssl_channel_credentials,
166169
quota_project_id=quota_project_id,

google/cloud/language_v1beta2/services/language_service/transports/grpc_asyncio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ def __init__(
204204
if not self._grpc_channel:
205205
self._grpc_channel = type(self).create_channel(
206206
self._host,
207+
# use the credentials which are saved
207208
credentials=self._credentials,
208-
credentials_file=credentials_file,
209+
# Set ``credentials_file`` to ``None`` here as
210+
# the credentials that we saved earlier should be used.
211+
credentials_file=None,
209212
scopes=self._scopes,
210213
ssl_credentials=self._ssl_channel_credentials,
211214
quota_project_id=quota_project_id,
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
google-cloud-language==2.3.1
22
numpy==1.22.1; python_version > '3.7'
33
numpy==1.21.4; python_version == '3.7'
4-
numpy==1.19.5; python_version <= '3.6'

tests/unit/gapic/language_v1/test_language_service.py

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,21 +519,28 @@ def test_language_service_client_client_options_scopes(
519519

520520

521521
@pytest.mark.parametrize(
522-
"client_class,transport_class,transport_name",
522+
"client_class,transport_class,transport_name,grpc_helpers",
523523
[
524-
(LanguageServiceClient, transports.LanguageServiceGrpcTransport, "grpc"),
524+
(
525+
LanguageServiceClient,
526+
transports.LanguageServiceGrpcTransport,
527+
"grpc",
528+
grpc_helpers,
529+
),
525530
(
526531
LanguageServiceAsyncClient,
527532
transports.LanguageServiceGrpcAsyncIOTransport,
528533
"grpc_asyncio",
534+
grpc_helpers_async,
529535
),
530536
],
531537
)
532538
def test_language_service_client_client_options_credentials_file(
533-
client_class, transport_class, transport_name
539+
client_class, transport_class, transport_name, grpc_helpers
534540
):
535541
# Check the case credentials file is provided.
536542
options = client_options.ClientOptions(credentials_file="credentials.json")
543+
537544
with mock.patch.object(transport_class, "__init__") as patched:
538545
patched.return_value = None
539546
client = client_class(client_options=options, transport=transport_name)
@@ -569,6 +576,75 @@ def test_language_service_client_client_options_from_dict():
569576
)
570577

571578

579+
@pytest.mark.parametrize(
580+
"client_class,transport_class,transport_name,grpc_helpers",
581+
[
582+
(
583+
LanguageServiceClient,
584+
transports.LanguageServiceGrpcTransport,
585+
"grpc",
586+
grpc_helpers,
587+
),
588+
(
589+
LanguageServiceAsyncClient,
590+
transports.LanguageServiceGrpcAsyncIOTransport,
591+
"grpc_asyncio",
592+
grpc_helpers_async,
593+
),
594+
],
595+
)
596+
def test_language_service_client_create_channel_credentials_file(
597+
client_class, transport_class, transport_name, grpc_helpers
598+
):
599+
# Check the case credentials file is provided.
600+
options = client_options.ClientOptions(credentials_file="credentials.json")
601+
602+
with mock.patch.object(transport_class, "__init__") as patched:
603+
patched.return_value = None
604+
client = client_class(client_options=options, transport=transport_name)
605+
patched.assert_called_once_with(
606+
credentials=None,
607+
credentials_file="credentials.json",
608+
host=client.DEFAULT_ENDPOINT,
609+
scopes=None,
610+
client_cert_source_for_mtls=None,
611+
quota_project_id=None,
612+
client_info=transports.base.DEFAULT_CLIENT_INFO,
613+
always_use_jwt_access=True,
614+
)
615+
616+
# test that the credentials from file are saved and used as the credentials.
617+
with mock.patch.object(
618+
google.auth, "load_credentials_from_file", autospec=True
619+
) as load_creds, mock.patch.object(
620+
google.auth, "default", autospec=True
621+
) as adc, mock.patch.object(
622+
grpc_helpers, "create_channel"
623+
) as create_channel:
624+
creds = ga_credentials.AnonymousCredentials()
625+
file_creds = ga_credentials.AnonymousCredentials()
626+
load_creds.return_value = (file_creds, None)
627+
adc.return_value = (creds, None)
628+
client = client_class(client_options=options, transport=transport_name)
629+
create_channel.assert_called_with(
630+
"language.googleapis.com:443",
631+
credentials=file_creds,
632+
credentials_file=None,
633+
quota_project_id=None,
634+
default_scopes=(
635+
"https://www.googleapis.com/auth/cloud-language",
636+
"https://www.googleapis.com/auth/cloud-platform",
637+
),
638+
scopes=None,
639+
default_host="language.googleapis.com",
640+
ssl_credentials=None,
641+
options=[
642+
("grpc.max_send_message_length", -1),
643+
("grpc.max_receive_message_length", -1),
644+
],
645+
)
646+
647+
572648
@pytest.mark.parametrize(
573649
"request_type", [language_service.AnalyzeSentimentRequest, dict,]
574650
)

0 commit comments

Comments
 (0)