Skip to content

Commit 83b2b9a

Browse files
busunkim96dizcologyvinnysenthil
committed
chore: update dev with changes to master (googleapis#33)
* Export aiplatform_v1beta1 as aiplatform.gapic_v1beta1 (googleapis#17) Freeing up the google.cloud.aiplatform namespace for MB SDK * GAPIC namespace (googleapis#20) * name space google.cloud.aiplatform.gapic * Init Disclaimer (googleapis#28) * clean up docstrings that are not rendered properly in reference doc (googleapis#24) Co-authored-by: Vinny Senthil <vinnysenthil@gmail.com> * fix: re-add py sessions to noxfile (googleapis#22) * fix: re-add py sessions to noxfile Co-authored-by: Vinny Senthil <vinnysenthil@gmail.com> Co-authored-by: Yu-Han Liu <yuhanliu@google.com> Co-authored-by: Vinny Senthil <vinnysenthil@gmail.com>
1 parent 8e50f3b commit 83b2b9a

File tree

10 files changed

+553
-2192
lines changed

10 files changed

+553
-2192
lines changed

README.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ Python Client for Cloud AI Platform
44
|beta| |pypi| |versions|
55

66

7-
`Cloud AI Platform`_: Google Cloud AI Platform is an integrated suite of machine learning tools and services for building and using ML models with AutoML or custom code. It offers both novices and experts the best workbench for the entire machine learning development lifecycle.
7+
:Warning: This library is a pre-release product and is subject to breaking changes.
8+
9+
`Cloud AI Platform`_: Cloud AI Platform is a suite of machine learning tools that enables
10+
developers to train high-quality models specific to their business needs.
11+
It offers both novices and experts the best workbench for machine learning
12+
development by leveraging Google's state-of-the-art transfer learning and
13+
Neural Architecture Search technology.
814

915
- `Client Library Documentation`_
1016
- `Product Documentation`_
@@ -15,9 +21,9 @@ Python Client for Cloud AI Platform
1521
:target: https://pypi.org/project/google-cloud-aiplatform/
1622
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-aiplatform.svg
1723
:target: https://pypi.org/project/google-cloud-aiplatform/
18-
.. _Cloud AI Platform: https://cloud.google.com/ai-platform-unified/docs
24+
.. _Cloud AI Platform: https://cloud.google.com/ai-platform/docs
1925
.. _Client Library Documentation: https://googleapis.dev/python/aiplatform/latest
20-
.. _Product Documentation: https://cloud.google.com/ai-platform-unified/docs
26+
.. _Product Documentation: https://cloud.google.com/ai-platform/docs
2127

2228
Quick Start
2329
-----------
@@ -79,5 +85,5 @@ Next Steps
7985
- View this `README`_ to see the full list of Cloud
8086
APIs that we cover.
8187

82-
.. _Cloud AI Platform API Product documentation: https://cloud.google.com/ai-platform-unified/docs
88+
.. _Cloud AI Platform API Product documentation: https://cloud.google.com/ai-platform/docs
8389
.. _README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst

google/cloud/aiplatform_v1beta1/services/job_service/client.py

Lines changed: 247 additions & 630 deletions
Large diffs are not rendered by default.

google/cloud/aiplatform_v1beta1/services/pipeline_service/client.py

Lines changed: 70 additions & 316 deletions
Large diffs are not rendered by default.

google/cloud/aiplatform_v1beta1/services/prediction_service/client.py

Lines changed: 46 additions & 267 deletions
Large diffs are not rendered by default.

google/cloud/aiplatform_v1beta1/services/prediction_service/transports/grpc.py

Lines changed: 28 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,16 @@
1515
# limitations under the License.
1616
#
1717

18-
import warnings
19-
from typing import Callable, Dict, Optional, Sequence, Tuple
18+
from typing import Callable, Dict
2019

2120
from google.api_core import grpc_helpers # type: ignore
22-
from google.api_core import gapic_v1 # type: ignore
23-
from google import auth # type: ignore
2421
from google.auth import credentials # type: ignore
25-
from google.auth.transport.grpc import SslCredentials # type: ignore
2622

2723
import grpc # type: ignore
2824

2925
from google.cloud.aiplatform_v1beta1.types import prediction_service
3026

31-
from .base import PredictionServiceTransport, DEFAULT_CLIENT_INFO
27+
from .base import PredictionServiceTransport
3228

3329

3430
class PredictionServiceGrpcTransport(PredictionServiceTransport):
@@ -44,21 +40,12 @@ class PredictionServiceGrpcTransport(PredictionServiceTransport):
4440
top of HTTP/2); the ``grpcio`` package must be installed.
4541
"""
4642

47-
_stubs: Dict[str, Callable]
48-
4943
def __init__(
5044
self,
5145
*,
5246
host: str = "aiplatform.googleapis.com",
5347
credentials: credentials.Credentials = None,
54-
credentials_file: str = None,
55-
scopes: Sequence[str] = None,
56-
channel: grpc.Channel = None,
57-
api_mtls_endpoint: str = None,
58-
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
59-
ssl_channel_credentials: grpc.ChannelCredentials = None,
60-
quota_project_id: Optional[str] = None,
61-
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
48+
channel: grpc.Channel = None
6249
) -> None:
6350
"""Instantiate the transport.
6451
@@ -70,123 +57,28 @@ def __init__(
7057
are specified, the client will attempt to ascertain the
7158
credentials from the environment.
7259
This argument is ignored if ``channel`` is provided.
73-
credentials_file (Optional[str]): A file with credentials that can
74-
be loaded with :func:`google.auth.load_credentials_from_file`.
75-
This argument is ignored if ``channel`` is provided.
76-
scopes (Optional(Sequence[str])): A list of scopes. This argument is
77-
ignored if ``channel`` is provided.
7860
channel (Optional[grpc.Channel]): A ``Channel`` instance through
7961
which to make calls.
80-
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
81-
If provided, it overrides the ``host`` argument and tries to create
82-
a mutual TLS channel with client SSL credentials from
83-
``client_cert_source`` or applicatin default SSL credentials.
84-
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
85-
Deprecated. A callback to provide client SSL certificate bytes and
86-
private key bytes, both in PEM format. It is ignored if
87-
``api_mtls_endpoint`` is None.
88-
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
89-
for grpc channel. It is ignored if ``channel`` is provided.
90-
quota_project_id (Optional[str]): An optional project to use for billing
91-
and quota.
92-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
93-
The client info used to send a user-agent string along with
94-
API requests. If ``None``, then default info will be used.
95-
Generally, you only need to set this if you're developing
96-
your own client library.
97-
98-
Raises:
99-
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
100-
creation failed for any reason.
101-
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
102-
and ``credentials_file`` are passed.
10362
"""
104-
self._ssl_channel_credentials = ssl_channel_credentials
105-
63+
# Sanity check: Ensure that channel and credentials are not both
64+
# provided.
10665
if channel:
107-
# Sanity check: Ensure that channel and credentials are not both
108-
# provided.
10966
credentials = False
11067

111-
# If a channel was explicitly provided, set it.
112-
self._grpc_channel = channel
113-
self._ssl_channel_credentials = None
114-
elif api_mtls_endpoint:
115-
warnings.warn(
116-
"api_mtls_endpoint and client_cert_source are deprecated",
117-
DeprecationWarning,
118-
)
119-
120-
host = (
121-
api_mtls_endpoint
122-
if ":" in api_mtls_endpoint
123-
else api_mtls_endpoint + ":443"
124-
)
125-
126-
if credentials is None:
127-
credentials, _ = auth.default(
128-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
129-
)
130-
131-
# Create SSL credentials with client_cert_source or application
132-
# default SSL credentials.
133-
if client_cert_source:
134-
cert, key = client_cert_source()
135-
ssl_credentials = grpc.ssl_channel_credentials(
136-
certificate_chain=cert, private_key=key
137-
)
138-
else:
139-
ssl_credentials = SslCredentials().ssl_credentials
140-
141-
# create a new channel. The provided one is ignored.
142-
self._grpc_channel = type(self).create_channel(
143-
host,
144-
credentials=credentials,
145-
credentials_file=credentials_file,
146-
ssl_credentials=ssl_credentials,
147-
scopes=scopes or self.AUTH_SCOPES,
148-
quota_project_id=quota_project_id,
149-
)
150-
self._ssl_channel_credentials = ssl_credentials
151-
else:
152-
host = host if ":" in host else host + ":443"
153-
154-
if credentials is None:
155-
credentials, _ = auth.default(
156-
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
157-
)
158-
159-
# create a new channel. The provided one is ignored.
160-
self._grpc_channel = type(self).create_channel(
161-
host,
162-
credentials=credentials,
163-
credentials_file=credentials_file,
164-
ssl_credentials=ssl_channel_credentials,
165-
scopes=scopes or self.AUTH_SCOPES,
166-
quota_project_id=quota_project_id,
167-
)
168-
68+
# Run the base constructor.
69+
super().__init__(host=host, credentials=credentials)
16970
self._stubs = {} # type: Dict[str, Callable]
17071

171-
# Run the base constructor.
172-
super().__init__(
173-
host=host,
174-
credentials=credentials,
175-
credentials_file=credentials_file,
176-
scopes=scopes or self.AUTH_SCOPES,
177-
quota_project_id=quota_project_id,
178-
client_info=client_info,
179-
)
72+
# If a channel was explicitly provided, set it.
73+
if channel:
74+
self._grpc_channel = channel
18075

18176
@classmethod
18277
def create_channel(
18378
cls,
18479
host: str = "aiplatform.googleapis.com",
18580
credentials: credentials.Credentials = None,
186-
credentials_file: str = None,
187-
scopes: Optional[Sequence[str]] = None,
188-
quota_project_id: Optional[str] = None,
189-
**kwargs,
81+
**kwargs
19082
) -> grpc.Channel:
19183
"""Create and return a gRPC channel object.
19284
Args:
@@ -196,37 +88,30 @@ def create_channel(
19688
credentials identify this application to the service. If
19789
none are specified, the client will attempt to ascertain
19890
the credentials from the environment.
199-
credentials_file (Optional[str]): A file with credentials that can
200-
be loaded with :func:`google.auth.load_credentials_from_file`.
201-
This argument is mutually exclusive with credentials.
202-
scopes (Optional[Sequence[str]]): A optional list of scopes needed for this
203-
service. These are only used when credentials are not specified and
204-
are passed to :func:`google.auth.default`.
205-
quota_project_id (Optional[str]): An optional project to use for billing
206-
and quota.
20791
kwargs (Optional[dict]): Keyword arguments, which are passed to the
20892
channel creation.
20993
Returns:
21094
grpc.Channel: A gRPC channel object.
211-
212-
Raises:
213-
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
214-
and ``credentials_file`` are passed.
21595
"""
216-
scopes = scopes or cls.AUTH_SCOPES
21796
return grpc_helpers.create_channel(
218-
host,
219-
credentials=credentials,
220-
credentials_file=credentials_file,
221-
scopes=scopes,
222-
quota_project_id=quota_project_id,
223-
**kwargs,
97+
host, credentials=credentials, scopes=cls.AUTH_SCOPES, **kwargs
22498
)
22599

226100
@property
227101
def grpc_channel(self) -> grpc.Channel:
228-
"""Return the channel designed to connect to this service.
102+
"""Create the channel designed to connect to this service.
103+
104+
This property caches on the instance; repeated calls return
105+
the same channel.
229106
"""
107+
# Sanity check: Only create a new channel if we do not already
108+
# have one.
109+
if not hasattr(self, "_grpc_channel"):
110+
self._grpc_channel = self.create_channel(
111+
self._host, credentials=self._credentials,
112+
)
113+
114+
# Return the channel from cache.
230115
return self._grpc_channel
231116

232117
@property
@@ -267,13 +152,11 @@ def explain(
267152
268153
Perform an online explanation.
269154
270-
If
271-
``deployed_model_id``
272-
is specified, the corresponding DeployModel must have
155+
If [ExplainRequest.deployed_model_id] is specified, the
156+
corresponding DeployModel must have
273157
``explanation_spec``
274-
populated. If
275-
``deployed_model_id``
276-
is not specified, all DeployedModels must have
158+
populated. If [ExplainRequest.deployed_model_id] is not
159+
specified, all DeployedModels must have
277160
``explanation_spec``
278161
populated. Only deployed AutoML tabular Models have
279162
explanation_spec.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy