GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Revert "feat: add always_use_jwt_access (#498)" (#552) · RCLDevelopers/python-aiplatform@fdeb51b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • google/cloud
    • aiplatform_v1beta1/services
      • dataset_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • endpoint_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • featurestore_online_serving_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • featurestore_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • index_endpoint_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • index_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • job_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • metadata_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • migration_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • model_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • pipeline_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • prediction_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • specialist_pool_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • tensorboard_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • vizier_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
    • aiplatform_v1/services
      • dataset_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • endpoint_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • job_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • migration_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • model_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • pipeline_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • prediction_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
      • specialist_pool_service/transports
        • base.py
        • grpc.py
        • grpc_asyncio.py
  • owlbot.py
  • schema/predict
    • instance
      • noxfile.py
      • setup.py
    • params
      • noxfile.py
      • setup.py
    • prediction
      • noxfile.py
      • setup.py
  • setup.py
  • testing
    • constraints-3.6.txt
  • tests/unit/gapic
    • aiplatform_v1beta1
      • test_dataset_service.py
      • test_endpoint_service.py
      • test_featurestore_online_serving_service.py
      • test_featurestore_service.py
      • test_index_endpoint_service.py
      • test_index_service.py
      • test_job_service.py
      • test_metadata_service.py
      • test_migration_service.py
      • test_model_service.py
      • test_pipeline_service.py
      • test_prediction_service.py
      • test_specialist_pool_service.py
      • test_tensorboard_service.py
      • test_vizier_service.py
    • aiplatform_v1
      • test_dataset_service.py
      • test_endpoint_service.py
      • test_job_service.py
      • test_migration_service.py
      • test_model_service.py
      • test_pipeline_service.py
      • test_prediction_service.py
      • test_specialist_pool_service.py
    • definition_v1beta1
      • __init__.py
    • definition_v1
      • __init__.py
    • instance_v1beta1
      • __init__.py
    • instance_v1
      • __init__.py
    • params_v1beta1
      • __init__.py
    • params_v1
      • __init__.py
    • prediction_v1beta1
      • __init__.py
    • prediction_v1
      • __init__.py

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎google/cloud/aiplatform_v1/services/dataset_service/transports/base.py‎

Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/dataset_service/transports/base.py
+27-15Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from google.api_core import retry as retries # type: ignore
2626
from google.api_core import operations_v1 # type: ignore
2727
from google.auth import credentials as ga_credentials # type: ignore
28-
from google.oauth2 import service_account # type: ignore
2928

3029
from google.cloud.aiplatform_v1.types import annotation_spec
3130
from google.cloud.aiplatform_v1.types import dataset
@@ -51,6 +50,8 @@
5150
except pkg_resources.DistributionNotFound: # pragma: NO COVER
5251
_GOOGLE_AUTH_VERSION = None
5352

53+
_API_CORE_VERSION = google.api_core.__version__
54+
5455

5556
class DatasetServiceTransport(abc.ABC):
5657
"""Abstract transport class for DatasetService."""
@@ -68,7 +69,6 @@ def __init__(
6869
scopes: Optional[Sequence[str]] = None,
6970
quota_project_id: Optional[str] = None,
7071
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
71-
always_use_jwt_access: Optional[bool] = False,
7272
**kwargs,
7373
) -> None:
7474
"""Instantiate the transport.
@@ -92,8 +92,6 @@ def __init__(
9292
API requests. If ``None``, then default info will be used.
9393
Generally, you only need to set this if you're developing
9494
your own client library.
95-
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
96-
be used for service account credentials.
9795
"""
9896
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
9997
if ":" not in host:
@@ -103,7 +101,7 @@ def __init__(
103101
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
104102

105103
# Save the scopes.
106-
self._scopes = scopes
104+
self._scopes = scopes or self.AUTH_SCOPES
107105

108106
# If no credentials are provided, then determine the appropriate
109107
# defaults.
@@ -122,20 +120,13 @@ def __init__(
122120
**scopes_kwargs, quota_project_id=quota_project_id
123121
)
124122

125-
# If the credentials is service account credentials, then always try to use self signed JWT.
126-
if (
127-
always_use_jwt_access
128-
and isinstance(credentials, service_account.Credentials)
129-
and hasattr(service_account.Credentials, "with_always_use_jwt_access")
130-
):
131-
credentials = credentials.with_always_use_jwt_access(True)
132-
133123
# Save the credentials.
134124
self._credentials = credentials
135125

136-
# TODO(busunkim): This method is in the base transport
126+
# TODO(busunkim): These two class methods are in the base transport
137127
# to avoid duplicating code across the transport classes. These functions
138-
# should be deleted once the minimum required versions of google-auth is increased.
128+
# should be deleted once the minimum required versions of google-api-core
129+
# and google-auth are increased.
139130

140131
# TODO: Remove this function once google-auth >= 1.25.0 is required
141132
@classmethod
@@ -156,6 +147,27 @@ def _get_scopes_kwargs(
156147

157148
return scopes_kwargs
158149

150+
# TODO: Remove this function once google-api-core >= 1.26.0 is required
151+
@classmethod
152+
def _get_self_signed_jwt_kwargs(
153+
cls, host: str, scopes: Optional[Sequence[str]]
154+
) -> Dict[str, Union[Optional[Sequence[str]], str]]:
155+
"""Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
156+
157+
self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
158+
159+
if _API_CORE_VERSION and (
160+
packaging.version.parse(_API_CORE_VERSION)
161+
>= packaging.version.parse("1.26.0")
162+
):
163+
self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
164+
self_signed_jwt_kwargs["scopes"] = scopes
165+
self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
166+
else:
167+
self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
168+
169+
return self_signed_jwt_kwargs
170+
159171
def _prep_wrapped_messages(self, client_info):
160172
# Precompute the wrapped methods.
161173
self._wrapped_methods = {
Collapse file

‎google/cloud/aiplatform_v1/services/dataset_service/transports/grpc.py‎

Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/dataset_service/transports/grpc.py
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def __init__(
6060
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6161
quota_project_id: Optional[str] = None,
6262
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
63-
always_use_jwt_access: Optional[bool] = False,
6463
) -> None:
6564
"""Instantiate the transport.
6665
@@ -101,8 +100,6 @@ def __init__(
101100
API requests. If ``None``, then default info will be used.
102101
Generally, you only need to set this if you're developing
103102
your own client library.
104-
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
105-
be used for service account credentials.
106103
107104
Raises:
108105
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -156,7 +153,6 @@ def __init__(
156153
scopes=scopes,
157154
quota_project_id=quota_project_id,
158155
client_info=client_info,
159-
always_use_jwt_access=always_use_jwt_access,
160156
)
161157

162158
if not self._grpc_channel:
@@ -212,14 +208,14 @@ def create_channel(
212208
and ``credentials_file`` are passed.
213209
"""
214210

211+
self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
212+
215213
return grpc_helpers.create_channel(
216214
host,
217215
credentials=credentials,
218216
credentials_file=credentials_file,
219217
quota_project_id=quota_project_id,
220-
default_scopes=cls.AUTH_SCOPES,
221-
scopes=scopes,
222-
default_host=cls.DEFAULT_HOST,
218+
**self_signed_jwt_kwargs,
223219
**kwargs,
224220
)
225221

Collapse file

‎google/cloud/aiplatform_v1/services/dataset_service/transports/grpc_asyncio.py‎

Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/dataset_service/transports/grpc_asyncio.py
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ def create_channel(
8181
aio.Channel: A gRPC AsyncIO channel object.
8282
"""
8383

84+
self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
85+
8486
return grpc_helpers_async.create_channel(
8587
host,
8688
credentials=credentials,
8789
credentials_file=credentials_file,
8890
quota_project_id=quota_project_id,
89-
default_scopes=cls.AUTH_SCOPES,
90-
scopes=scopes,
91-
default_host=cls.DEFAULT_HOST,
91+
**self_signed_jwt_kwargs,
9292
**kwargs,
9393
)
9494

@@ -106,7 +106,6 @@ def __init__(
106106
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
107107
quota_project_id=None,
108108
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
109-
always_use_jwt_access: Optional[bool] = False,
110109
) -> None:
111110
"""Instantiate the transport.
112111
@@ -148,8 +147,6 @@ def __init__(
148147
API requests. If ``None``, then default info will be used.
149148
Generally, you only need to set this if you're developing
150149
your own client library.
151-
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
152-
be used for service account credentials.
153150
154151
Raises:
155152
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -202,7 +199,6 @@ def __init__(
202199
scopes=scopes,
203200
quota_project_id=quota_project_id,
204201
client_info=client_info,
205-
always_use_jwt_access=always_use_jwt_access,
206202
)
207203

208204
if not self._grpc_channel:
Collapse file

‎google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py‎

Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py
+27-15Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from google.api_core import retry as retries # type: ignore
2626
from google.api_core import operations_v1 # type: ignore
2727
from google.auth import credentials as ga_credentials # type: ignore
28-
from google.oauth2 import service_account # type: ignore
2928

3029
from google.cloud.aiplatform_v1.types import endpoint
3130
from google.cloud.aiplatform_v1.types import endpoint as gca_endpoint
@@ -50,6 +49,8 @@
5049
except pkg_resources.DistributionNotFound: # pragma: NO COVER
5150
_GOOGLE_AUTH_VERSION = None
5251

52+
_API_CORE_VERSION = google.api_core.__version__
53+
5354

5455
class EndpointServiceTransport(abc.ABC):
5556
"""Abstract transport class for EndpointService."""
@@ -67,7 +68,6 @@ def __init__(
6768
scopes: Optional[Sequence[str]] = None,
6869
quota_project_id: Optional[str] = None,
6970
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
70-
always_use_jwt_access: Optional[bool] = False,
7171
**kwargs,
7272
) -> None:
7373
"""Instantiate the transport.
@@ -91,8 +91,6 @@ def __init__(
9191
API requests. If ``None``, then default info will be used.
9292
Generally, you only need to set this if you're developing
9393
your own client library.
94-
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
95-
be used for service account credentials.
9694
"""
9795
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
9896
if ":" not in host:
@@ -102,7 +100,7 @@ def __init__(
102100
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
103101

104102
# Save the scopes.
105-
self._scopes = scopes
103+
self._scopes = scopes or self.AUTH_SCOPES
106104

107105
# If no credentials are provided, then determine the appropriate
108106
# defaults.
@@ -121,20 +119,13 @@ def __init__(
121119
**scopes_kwargs, quota_project_id=quota_project_id
122120
)
123121

124-
# If the credentials is service account credentials, then always try to use self signed JWT.
125-
if (
126-
always_use_jwt_access
127-
and isinstance(credentials, service_account.Credentials)
128-
and hasattr(service_account.Credentials, "with_always_use_jwt_access")
129-
):
130-
credentials = credentials.with_always_use_jwt_access(True)
131-
132122
# Save the credentials.
133123
self._credentials = credentials
134124

135-
# TODO(busunkim): This method is in the base transport
125+
# TODO(busunkim): These two class methods are in the base transport
136126
# to avoid duplicating code across the transport classes. These functions
137-
# should be deleted once the minimum required versions of google-auth is increased.
127+
# should be deleted once the minimum required versions of google-api-core
128+
# and google-auth are increased.
138129

139130
# TODO: Remove this function once google-auth >= 1.25.0 is required
140131
@classmethod
@@ -155,6 +146,27 @@ def _get_scopes_kwargs(
155146

156147
return scopes_kwargs
157148

149+
# TODO: Remove this function once google-api-core >= 1.26.0 is required
150+
@classmethod
151+
def _get_self_signed_jwt_kwargs(
152+
cls, host: str, scopes: Optional[Sequence[str]]
153+
) -> Dict[str, Union[Optional[Sequence[str]], str]]:
154+
"""Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version"""
155+
156+
self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {}
157+
158+
if _API_CORE_VERSION and (
159+
packaging.version.parse(_API_CORE_VERSION)
160+
>= packaging.version.parse("1.26.0")
161+
):
162+
self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES
163+
self_signed_jwt_kwargs["scopes"] = scopes
164+
self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST
165+
else:
166+
self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES
167+
168+
return self_signed_jwt_kwargs
169+
158170
def _prep_wrapped_messages(self, client_info):
159171
# Precompute the wrapped methods.
160172
self._wrapped_methods = {
Collapse file

‎google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc.py‎

Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc.py
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def __init__(
5959
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
6060
quota_project_id: Optional[str] = None,
6161
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
62-
always_use_jwt_access: Optional[bool] = False,
6362
) -> None:
6463
"""Instantiate the transport.
6564
@@ -100,8 +99,6 @@ def __init__(
10099
API requests. If ``None``, then default info will be used.
101100
Generally, you only need to set this if you're developing
102101
your own client library.
103-
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
104-
be used for service account credentials.
105102
106103
Raises:
107104
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -155,7 +152,6 @@ def __init__(
155152
scopes=scopes,
156153
quota_project_id=quota_project_id,
157154
client_info=client_info,
158-
always_use_jwt_access=always_use_jwt_access,
159155
)
160156

161157
if not self._grpc_channel:
@@ -211,14 +207,14 @@ def create_channel(
211207
and ``credentials_file`` are passed.
212208
"""
213209

210+
self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
211+
214212
return grpc_helpers.create_channel(
215213
host,
216214
credentials=credentials,
217215
credentials_file=credentials_file,
218216
quota_project_id=quota_project_id,
219-
default_scopes=cls.AUTH_SCOPES,
220-
scopes=scopes,
221-
default_host=cls.DEFAULT_HOST,
217+
**self_signed_jwt_kwargs,
222218
**kwargs,
223219
)
224220

Collapse file

‎google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc_asyncio.py‎

Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/endpoint_service/transports/grpc_asyncio.py
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ def create_channel(
8080
aio.Channel: A gRPC AsyncIO channel object.
8181
"""
8282

83+
self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes)
84+
8385
return grpc_helpers_async.create_channel(
8486
host,
8587
credentials=credentials,
8688
credentials_file=credentials_file,
8789
quota_project_id=quota_project_id,
88-
default_scopes=cls.AUTH_SCOPES,
89-
scopes=scopes,
90-
default_host=cls.DEFAULT_HOST,
90+
**self_signed_jwt_kwargs,
9191
**kwargs,
9292
)
9393

@@ -105,7 +105,6 @@ def __init__(
105105
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
106106
quota_project_id=None,
107107
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
108-
always_use_jwt_access: Optional[bool] = False,
109108
) -> None:
110109
"""Instantiate the transport.
111110
@@ -147,8 +146,6 @@ def __init__(
147146
API requests. If ``None``, then default info will be used.
148147
Generally, you only need to set this if you're developing
149148
your own client library.
150-
always_use_jwt_access (Optional[bool]): Whether self signed JWT should
151-
be used for service account credentials.
152149
153150
Raises:
154151
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -201,7 +198,6 @@ def __init__(
201198
scopes=scopes,
202199
quota_project_id=quota_project_id,
203200
client_info=client_info,
204-
always_use_jwt_access=always_use_jwt_access,
205201
)
206202

207203
if not self._grpc_channel:

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.