Skip to content

Commit e356f5a

Browse files
gcf-owl-bot[bot]copybara-github
authored andcommitted
Copybara import of the project:
-- 0966deb by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>: feat: add Model Garden deploy API PiperOrigin-RevId: 729261558 Source-Link: googleapis/googleapis@7e791c0 Source-Link: googleapis/googleapis-gen@3dbfe2e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiM2RiZmUyZTZiYjQ3NmQ2MTk3OWUzOWFiOThlZDkxZThjZDdmYjk2YSJ9 -- 643a485 by Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>: 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md COPYBARA_INTEGRATE_REVIEW=#4977 from googleapis:owl-bot-copy 97fdb22 PiperOrigin-RevId: 730634172
1 parent 8cefabb commit e356f5a

19 files changed

+2139
-88
lines changed

google/cloud/aiplatform_v1beta1/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,12 @@
762762
)
763763
from .types.model_evaluation import ModelEvaluation
764764
from .types.model_evaluation_slice import ModelEvaluationSlice
765+
from .types.model_garden_service import DeployOperationMetadata
765766
from .types.model_garden_service import DeployPublisherModelOperationMetadata
766767
from .types.model_garden_service import DeployPublisherModelRequest
767768
from .types.model_garden_service import DeployPublisherModelResponse
769+
from .types.model_garden_service import DeployRequest
770+
from .types.model_garden_service import DeployResponse
768771
from .types.model_garden_service import GetPublisherModelRequest
769772
from .types.model_garden_service import ListPublisherModelsRequest
770773
from .types.model_garden_service import ListPublisherModelsResponse
@@ -1446,9 +1449,12 @@
14461449
"DeployModelOperationMetadata",
14471450
"DeployModelRequest",
14481451
"DeployModelResponse",
1452+
"DeployOperationMetadata",
14491453
"DeployPublisherModelOperationMetadata",
14501454
"DeployPublisherModelRequest",
14511455
"DeployPublisherModelResponse",
1456+
"DeployRequest",
1457+
"DeployResponse",
14521458
"DeployedIndex",
14531459
"DeployedIndexAuthConfig",
14541460
"DeployedIndexRef",

google/cloud/aiplatform_v1beta1/gapic_metadata.json

+15
Original file line numberDiff line numberDiff line change
@@ -3375,6 +3375,11 @@
33753375
"grpc": {
33763376
"libraryClient": "ModelGardenServiceClient",
33773377
"rpcs": {
3378+
"Deploy": {
3379+
"methods": [
3380+
"deploy"
3381+
]
3382+
},
33783383
"DeployPublisherModel": {
33793384
"methods": [
33803385
"deploy_publisher_model"
@@ -3395,6 +3400,11 @@
33953400
"grpc-async": {
33963401
"libraryClient": "ModelGardenServiceAsyncClient",
33973402
"rpcs": {
3403+
"Deploy": {
3404+
"methods": [
3405+
"deploy"
3406+
]
3407+
},
33983408
"DeployPublisherModel": {
33993409
"methods": [
34003410
"deploy_publisher_model"
@@ -3415,6 +3425,11 @@
34153425
"rest": {
34163426
"libraryClient": "ModelGardenServiceClient",
34173427
"rpcs": {
3428+
"Deploy": {
3429+
"methods": [
3430+
"deploy"
3431+
]
3432+
},
34183433
"DeployPublisherModel": {
34193434
"methods": [
34203435
"deploy_publisher_model"

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -264,40 +264,40 @@ def parse_dataset_path(path: str) -> Dict[str, str]:
264264
@staticmethod
265265
def dataset_path(
266266
project: str,
267+
location: str,
267268
dataset: str,
268269
) -> str:
269270
"""Returns a fully-qualified dataset string."""
270-
return "projects/{project}/datasets/{dataset}".format(
271+
return "projects/{project}/locations/{location}/datasets/{dataset}".format(
271272
project=project,
273+
location=location,
272274
dataset=dataset,
273275
)
274276

275277
@staticmethod
276278
def parse_dataset_path(path: str) -> Dict[str, str]:
277279
"""Parses a dataset path into its component segments."""
278-
m = re.match(r"^projects/(?P<project>.+?)/datasets/(?P<dataset>.+?)$", path)
280+
m = re.match(
281+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/datasets/(?P<dataset>.+?)$",
282+
path,
283+
)
279284
return m.groupdict() if m else {}
280285

281286
@staticmethod
282287
def dataset_path(
283288
project: str,
284-
location: str,
285289
dataset: str,
286290
) -> str:
287291
"""Returns a fully-qualified dataset string."""
288-
return "projects/{project}/locations/{location}/datasets/{dataset}".format(
292+
return "projects/{project}/datasets/{dataset}".format(
289293
project=project,
290-
location=location,
291294
dataset=dataset,
292295
)
293296

294297
@staticmethod
295298
def parse_dataset_path(path: str) -> Dict[str, str]:
296299
"""Parses a dataset path into its component segments."""
297-
m = re.match(
298-
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/datasets/(?P<dataset>.+?)$",
299-
path,
300-
)
300+
m = re.match(r"^projects/(?P<project>.+?)/datasets/(?P<dataset>.+?)$", path)
301301
return m.groupdict() if m else {}
302302

303303
@staticmethod

google/cloud/aiplatform_v1beta1/services/model_garden_service/async_client.py

+101
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,107 @@ async def sample_list_publisher_models():
542542
# Done; return the response.
543543
return response
544544

545+
async def deploy(
546+
self,
547+
request: Optional[Union[model_garden_service.DeployRequest, dict]] = None,
548+
*,
549+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
550+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
551+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
552+
) -> operation_async.AsyncOperation:
553+
r"""Deploys a model to a new endpoint.
554+
555+
.. code-block:: python
556+
557+
# This snippet has been automatically generated and should be regarded as a
558+
# code template only.
559+
# It will require modifications to work:
560+
# - It may require correct/in-range values for request initialization.
561+
# - It may require specifying regional endpoints when creating the service
562+
# client as shown in:
563+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
564+
from google.cloud import aiplatform_v1beta1
565+
566+
async def sample_deploy():
567+
# Create a client
568+
client = aiplatform_v1beta1.ModelGardenServiceAsyncClient()
569+
570+
# Initialize request argument(s)
571+
request = aiplatform_v1beta1.DeployRequest(
572+
publisher_model_name="publisher_model_name_value",
573+
destination="destination_value",
574+
)
575+
576+
# Make the request
577+
operation = client.deploy(request=request)
578+
579+
print("Waiting for operation to complete...")
580+
581+
response = (await operation).result()
582+
583+
# Handle the response
584+
print(response)
585+
586+
Args:
587+
request (Optional[Union[google.cloud.aiplatform_v1beta1.types.DeployRequest, dict]]):
588+
The request object. Request message for
589+
[ModelGardenService.Deploy][google.cloud.aiplatform.v1beta1.ModelGardenService.Deploy].
590+
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
591+
should be retried.
592+
timeout (float): The timeout for this request.
593+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
594+
sent along with the request as metadata. Normally, each value must be of type `str`,
595+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
596+
be of type `bytes`.
597+
598+
Returns:
599+
google.api_core.operation_async.AsyncOperation:
600+
An object representing a long-running operation.
601+
602+
The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.DeployResponse` Response message for
603+
[ModelGardenService.Deploy][google.cloud.aiplatform.v1beta1.ModelGardenService.Deploy].
604+
605+
"""
606+
# Create or coerce a protobuf request object.
607+
# - Use the request object if provided (there's no risk of modifying the input as
608+
# there are no flattened fields), or create one.
609+
if not isinstance(request, model_garden_service.DeployRequest):
610+
request = model_garden_service.DeployRequest(request)
611+
612+
# Wrap the RPC method; this adds retry and timeout information,
613+
# and friendly error handling.
614+
rpc = self._client._transport._wrapped_methods[self._client._transport.deploy]
615+
616+
# Certain fields should be provided within the metadata header;
617+
# add these here.
618+
metadata = tuple(metadata) + (
619+
gapic_v1.routing_header.to_grpc_metadata(
620+
(("destination", request.destination),)
621+
),
622+
)
623+
624+
# Validate the universe domain.
625+
self._client._validate_universe_domain()
626+
627+
# Send the request.
628+
response = await rpc(
629+
request,
630+
retry=retry,
631+
timeout=timeout,
632+
metadata=metadata,
633+
)
634+
635+
# Wrap the response in an operation future.
636+
response = operation_async.from_gapic(
637+
response,
638+
self._client._transport.operations_client,
639+
model_garden_service.DeployResponse,
640+
metadata_type=model_garden_service.DeployOperationMetadata,
641+
)
642+
643+
# Done; return the response.
644+
return response
645+
545646
async def deploy_publisher_model(
546647
self,
547648
request: Optional[

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

+101
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,107 @@ def sample_list_publisher_models():
10491049
# Done; return the response.
10501050
return response
10511051

1052+
def deploy(
1053+
self,
1054+
request: Optional[Union[model_garden_service.DeployRequest, dict]] = None,
1055+
*,
1056+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1057+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1058+
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
1059+
) -> operation.Operation:
1060+
r"""Deploys a model to a new endpoint.
1061+
1062+
.. code-block:: python
1063+
1064+
# This snippet has been automatically generated and should be regarded as a
1065+
# code template only.
1066+
# It will require modifications to work:
1067+
# - It may require correct/in-range values for request initialization.
1068+
# - It may require specifying regional endpoints when creating the service
1069+
# client as shown in:
1070+
# https://googleapis.dev/python/google-api-core/latest/client_options.html
1071+
from google.cloud import aiplatform_v1beta1
1072+
1073+
def sample_deploy():
1074+
# Create a client
1075+
client = aiplatform_v1beta1.ModelGardenServiceClient()
1076+
1077+
# Initialize request argument(s)
1078+
request = aiplatform_v1beta1.DeployRequest(
1079+
publisher_model_name="publisher_model_name_value",
1080+
destination="destination_value",
1081+
)
1082+
1083+
# Make the request
1084+
operation = client.deploy(request=request)
1085+
1086+
print("Waiting for operation to complete...")
1087+
1088+
response = operation.result()
1089+
1090+
# Handle the response
1091+
print(response)
1092+
1093+
Args:
1094+
request (Union[google.cloud.aiplatform_v1beta1.types.DeployRequest, dict]):
1095+
The request object. Request message for
1096+
[ModelGardenService.Deploy][google.cloud.aiplatform.v1beta1.ModelGardenService.Deploy].
1097+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1098+
should be retried.
1099+
timeout (float): The timeout for this request.
1100+
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
1101+
sent along with the request as metadata. Normally, each value must be of type `str`,
1102+
but for metadata keys ending with the suffix `-bin`, the corresponding values must
1103+
be of type `bytes`.
1104+
1105+
Returns:
1106+
google.api_core.operation.Operation:
1107+
An object representing a long-running operation.
1108+
1109+
The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.DeployResponse` Response message for
1110+
[ModelGardenService.Deploy][google.cloud.aiplatform.v1beta1.ModelGardenService.Deploy].
1111+
1112+
"""
1113+
# Create or coerce a protobuf request object.
1114+
# - Use the request object if provided (there's no risk of modifying the input as
1115+
# there are no flattened fields), or create one.
1116+
if not isinstance(request, model_garden_service.DeployRequest):
1117+
request = model_garden_service.DeployRequest(request)
1118+
1119+
# Wrap the RPC method; this adds retry and timeout information,
1120+
# and friendly error handling.
1121+
rpc = self._transport._wrapped_methods[self._transport.deploy]
1122+
1123+
# Certain fields should be provided within the metadata header;
1124+
# add these here.
1125+
metadata = tuple(metadata) + (
1126+
gapic_v1.routing_header.to_grpc_metadata(
1127+
(("destination", request.destination),)
1128+
),
1129+
)
1130+
1131+
# Validate the universe domain.
1132+
self._validate_universe_domain()
1133+
1134+
# Send the request.
1135+
response = rpc(
1136+
request,
1137+
retry=retry,
1138+
timeout=timeout,
1139+
metadata=metadata,
1140+
)
1141+
1142+
# Wrap the response in an operation future.
1143+
response = operation.from_gapic(
1144+
response,
1145+
self._transport.operations_client,
1146+
model_garden_service.DeployResponse,
1147+
metadata_type=model_garden_service.DeployOperationMetadata,
1148+
)
1149+
1150+
# Done; return the response.
1151+
return response
1152+
10521153
def deploy_publisher_model(
10531154
self,
10541155
request: Optional[

google/cloud/aiplatform_v1beta1/services/model_garden_service/transports/base.py

+14
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ def _prep_wrapped_messages(self, client_info):
145145
default_timeout=None,
146146
client_info=client_info,
147147
),
148+
self.deploy: gapic_v1.method.wrap_method(
149+
self.deploy,
150+
default_timeout=None,
151+
client_info=client_info,
152+
),
148153
self.deploy_publisher_model: gapic_v1.method.wrap_method(
149154
self.deploy_publisher_model,
150155
default_timeout=None,
@@ -239,6 +244,15 @@ def list_publisher_models(
239244
]:
240245
raise NotImplementedError()
241246

247+
@property
248+
def deploy(
249+
self,
250+
) -> Callable[
251+
[model_garden_service.DeployRequest],
252+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
253+
]:
254+
raise NotImplementedError()
255+
242256
@property
243257
def deploy_publisher_model(
244258
self,

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

+26
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,32 @@ def list_publisher_models(
401401
)
402402
return self._stubs["list_publisher_models"]
403403

404+
@property
405+
def deploy(
406+
self,
407+
) -> Callable[[model_garden_service.DeployRequest], operations_pb2.Operation]:
408+
r"""Return a callable for the deploy method over gRPC.
409+
410+
Deploys a model to a new endpoint.
411+
412+
Returns:
413+
Callable[[~.DeployRequest],
414+
~.Operation]:
415+
A function that, when called, will call the underlying RPC
416+
on the server.
417+
"""
418+
# Generate a "stub function" on-the-fly which will actually make
419+
# the request.
420+
# gRPC handles serialization and deserialization, so we just need
421+
# to pass in the functions for each.
422+
if "deploy" not in self._stubs:
423+
self._stubs["deploy"] = self._logged_channel.unary_unary(
424+
"/google.cloud.aiplatform.v1beta1.ModelGardenService/Deploy",
425+
request_serializer=model_garden_service.DeployRequest.serialize,
426+
response_deserializer=operations_pb2.Operation.FromString,
427+
)
428+
return self._stubs["deploy"]
429+
404430
@property
405431
def deploy_publisher_model(
406432
self,

0 commit comments

Comments
 (0)