Content-Length: 796056 | pFad | https://www.github.com/googleapis/python-aiplatform/commit/89e321246b6223a2355947d8dbd0161b84523478

80F feat: add support for multiple client versions, change aiplatform fro… · googleapis/python-aiplatform@89e3212 · GitHub
Skip to content

Commit 89e3212

Browse files
morgandurenovate-botsasha-gitg
authored
feat: add support for multiple client versions, change aiplatform from compat.V1BETA1 to compat.V1 (#290)
* resolving rebase conflict, review feedback * change compat.DEFAULT_VERSION to compat.V1; change tests services and types to V1 for general; add fixtures to support V1BETA1 tests for explanation * chore(deps): update dependency google-cloud-aiplatform to v0.6.0 (#270) * fix: add v1 conversion value rule Co-authored-by: WhiteSource Renovate <bot@renovateapp.com> Co-authored-by: Sasha Sobran <asobran@google.com>
1 parent acd0a7c commit 89e3212

27 files changed

+1584
-792
lines changed

google/cloud/aiplatform/base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
import functools
2121
import inspect
2222
import threading
23-
from typing import Any, Callable, Dict, Optional, Sequence, Union
23+
from typing import Any, Callable, Dict, Optional, Sequence, Type, Union
2424

2525
import proto
2626

2727
from google.auth import credentials as auth_credentials
28-
from google.cloud.aiplatform import utils
2928
from google.cloud.aiplatform import initializer
29+
from google.cloud.aiplatform import utils
3030

3131

3232
class FutureManager(metaclass=abc.ABCMeta):
@@ -232,8 +232,8 @@ class AiPlatformResourceNoun(metaclass=abc.ABCMeta):
232232
@property
233233
@classmethod
234234
@abc.abstractmethod
235-
def client_class(cls) -> utils.AiPlatformServiceClient:
236-
"""Client class required to interact with resource."""
235+
def client_class(cls) -> Type[utils.AiPlatformServiceClientWithOverride]:
236+
"""Client class required to interact with resource with optional overrides."""
237237
pass
238238

239239
@property
@@ -287,7 +287,7 @@ def _instantiate_client(
287287
cls,
288288
location: Optional[str] = None,
289289
credentials: Optional[auth_credentials.Credentials] = None,
290-
) -> utils.AiPlatformServiceClient:
290+
) -> utils.AiPlatformServiceClientWithOverride:
291291
"""Helper method to instantiate service client for resource noun.
292292
293293
Args:
@@ -296,8 +296,8 @@ def _instantiate_client(
296296
Optional custom credentials to use when accessing interacting with
297297
resource noun.
298298
Returns:
299-
client (utils.AiPlatformServiceClient):
300-
Initialized service client for this service noun.
299+
client (utils.AiPlatformServiceClientWithOverride):
300+
Initialized service client for this service noun with optional overrides.
301301
"""
302302
return initializer.global_config.create_client(
303303
client_class=cls.client_class,
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Copyright 2021 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
from google.cloud.aiplatform.compat import services
19+
from google.cloud.aiplatform.compat import types
20+
21+
V1BETA1 = "v1beta1"
22+
V1 = "v1"
23+
24+
DEFAULT_VERSION = V1
25+
26+
if DEFAULT_VERSION == V1BETA1:
27+
28+
services.dataset_service_client = services.dataset_service_client_v1beta1
29+
services.endpoint_service_client = services.endpoint_service_client_v1beta1
30+
services.job_service_client = services.job_service_client_v1beta1
31+
services.model_service_client = services.model_service_client_v1beta1
32+
services.pipeline_service_client = services.pipeline_service_client_v1beta1
33+
services.prediction_service_client = services.prediction_service_client_v1beta1
34+
services.specialist_pool_service_client = (
35+
services.specialist_pool_service_client_v1beta1
36+
)
37+
38+
types.accelerator_type = types.accelerator_type_v1beta1
39+
types.annotation = types.annotation_v1beta1
40+
types.annotation_spec = types.annotation_spec_v1beta1
41+
types.batch_prediction_job = types.batch_prediction_job_v1beta1
42+
types.completion_stats = types.completion_stats_v1beta1
43+
types.custom_job = types.custom_job_v1beta1
44+
types.data_item = types.data_item_v1beta1
45+
types.data_labeling_job = types.data_labeling_job_v1beta1
46+
types.dataset = types.dataset_v1beta1
47+
types.dataset_service = types.dataset_service_v1beta1
48+
types.deployed_model_ref = types.deployed_model_ref_v1beta1
49+
types.encryption_spec = types.encryption_spec_v1beta1
50+
types.endpoint = types.endpoint_v1beta1
51+
types.endpoint_service = types.endpoint_service_v1beta1
52+
types.env_var = types.env_var_v1beta1
53+
types.explanation = types.explanation_v1beta1
54+
types.explanation_metadata = types.explanation_metadata_v1beta1
55+
types.hyperparameter_tuning_job = types.hyperparameter_tuning_job_v1beta1
56+
types.io = types.io_v1beta1
57+
types.job_service = types.job_service_v1beta1
58+
types.job_state = types.job_state_v1beta1
59+
types.machine_resources = types.machine_resources_v1beta1
60+
types.manual_batch_tuning_parameters = types.manual_batch_tuning_parameters_v1beta1
61+
types.model = types.model_v1beta1
62+
types.model_evaluation = types.model_evaluation_v1beta1
63+
types.model_evaluation_slice = types.model_evaluation_slice_v1beta1
64+
types.model_service = types.model_service_v1beta1
65+
types.operation = types.operation_v1beta1
66+
types.pipeline_service = types.pipeline_service_v1beta1
67+
types.pipeline_state = types.pipeline_state_v1beta1
68+
types.prediction_service = types.prediction_service_v1beta1
69+
types.specialist_pool = types.specialist_pool_v1beta1
70+
types.specialist_pool_service = types.specialist_pool_service_v1beta1
71+
types.training_pipeline = types.training_pipeline_v1beta1
72+
73+
if DEFAULT_VERSION == V1:
74+
75+
services.dataset_service_client = services.dataset_service_client_v1
76+
services.endpoint_service_client = services.endpoint_service_client_v1
77+
services.job_service_client = services.job_service_client_v1
78+
services.model_service_client = services.model_service_client_v1
79+
services.pipeline_service_client = services.pipeline_service_client_v1
80+
services.prediction_service_client = services.prediction_service_client_v1
81+
services.specialist_pool_service_client = services.specialist_pool_service_client_v1
82+
83+
types.accelerator_type = types.accelerator_type_v1
84+
types.annotation = types.annotation_v1
85+
types.annotation_spec = types.annotation_spec_v1
86+
types.batch_prediction_job = types.batch_prediction_job_v1
87+
types.completion_stats = types.completion_stats_v1
88+
types.custom_job = types.custom_job_v1
89+
types.data_item = types.data_item_v1
90+
types.data_labeling_job = types.data_labeling_job_v1
91+
types.dataset = types.dataset_v1
92+
types.dataset_service = types.dataset_service_v1
93+
types.deployed_model_ref = types.deployed_model_ref_v1
94+
types.encryption_spec = types.encryption_spec_v1
95+
types.endpoint = types.endpoint_v1
96+
types.endpoint_service = types.endpoint_service_v1
97+
types.env_var = types.env_var_v1
98+
types.hyperparameter_tuning_job = types.hyperparameter_tuning_job_v1
99+
types.io = types.io_v1
100+
types.job_service = types.job_service_v1
101+
types.job_state = types.job_state_v1
102+
types.machine_resources = types.machine_resources_v1
103+
types.manual_batch_tuning_parameters = types.manual_batch_tuning_parameters_v1
104+
types.model = types.model_v1
105+
types.model_evaluation = types.model_evaluation_v1
106+
types.model_evaluation_slice = types.model_evaluation_slice_v1
107+
types.model_service = types.model_service_v1
108+
types.operation = types.operation_v1
109+
types.pipeline_service = types.pipeline_service_v1
110+
types.pipeline_state = types.pipeline_state_v1
111+
types.prediction_service = types.prediction_service_v1
112+
types.specialist_pool = types.specialist_pool_v1
113+
types.specialist_pool_service = types.specialist_pool_service_v1
114+
types.training_pipeline = types.training_pipeline_v1
115+
116+
__all__ = (
117+
DEFAULT_VERSION,
118+
V1BETA1,
119+
V1,
120+
services,
121+
types,
122+
)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Copyright 2021 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
from google.cloud.aiplatform_v1beta1.services.dataset_service import (
19+
client as dataset_service_client_v1beta1,
20+
)
21+
from google.cloud.aiplatform_v1beta1.services.endpoint_service import (
22+
client as endpoint_service_client_v1beta1,
23+
)
24+
from google.cloud.aiplatform_v1beta1.services.job_service import (
25+
client as job_service_client_v1beta1,
26+
)
27+
from google.cloud.aiplatform_v1beta1.services.model_service import (
28+
client as model_service_client_v1beta1,
29+
)
30+
from google.cloud.aiplatform_v1beta1.services.pipeline_service import (
31+
client as pipeline_service_client_v1beta1,
32+
)
33+
from google.cloud.aiplatform_v1beta1.services.prediction_service import (
34+
client as prediction_service_client_v1beta1,
35+
)
36+
from google.cloud.aiplatform_v1beta1.services.specialist_pool_service import (
37+
client as specialist_pool_service_client_v1beta1,
38+
)
39+
40+
from google.cloud.aiplatform_v1.services.dataset_service import (
41+
client as dataset_service_client_v1,
42+
)
43+
from google.cloud.aiplatform_v1.services.endpoint_service import (
44+
client as endpoint_service_client_v1,
45+
)
46+
from google.cloud.aiplatform_v1.services.job_service import (
47+
client as job_service_client_v1,
48+
)
49+
from google.cloud.aiplatform_v1.services.model_service import (
50+
client as model_service_client_v1,
51+
)
52+
from google.cloud.aiplatform_v1.services.pipeline_service import (
53+
client as pipeline_service_client_v1,
54+
)
55+
from google.cloud.aiplatform_v1.services.prediction_service import (
56+
client as prediction_service_client_v1,
57+
)
58+
from google.cloud.aiplatform_v1.services.specialist_pool_service import (
59+
client as specialist_pool_service_client_v1,
60+
)
61+
62+
__all__ = (
63+
# v1
64+
dataset_service_client_v1,
65+
endpoint_service_client_v1,
66+
job_service_client_v1,
67+
model_service_client_v1,
68+
pipeline_service_client_v1,
69+
prediction_service_client_v1,
70+
specialist_pool_service_client_v1,
71+
# v1beta1
72+
dataset_service_client_v1beta1,
73+
endpoint_service_client_v1beta1,
74+
job_service_client_v1beta1,
75+
model_service_client_v1beta1,
76+
pipeline_service_client_v1beta1,
77+
prediction_service_client_v1beta1,
78+
specialist_pool_service_client_v1beta1,
79+
)

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://www.github.com/googleapis/python-aiplatform/commit/89e321246b6223a2355947d8dbd0161b84523478

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy