def deploy_model( self, request: endpoint_service.DeployModelRequest = None, *, endpoint: str = None, deployed_model: gca_endpoint.DeployedModel = None, traffic_split: Sequence[ endpoint_service.DeployModelRequest.TrafficSplitEntry ] = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> gac_operation.Operation: r"""Deploys a Model into this Endpoint, creating a DeployedModel within it. Args: request (google.cloud.aiplatform_v1beta1.types.DeployModelRequest): The request object. Request message for [EndpointService.DeployModel][google.cloud.aiplatform.v1beta1.EndpointService.DeployModel]. endpoint (str): Required. The name of the Endpoint resource into which to deploy a Model. Format: ``projects/{project}/locations/{location}/endpoints/{endpoint}`` This corresponds to the ``endpoint`` field on the ``request`` instance; if ``request`` is provided, this should not be set. deployed_model (google.cloud.aiplatform_v1beta1.types.DeployedModel): Required. The DeployedModel to be created within the Endpoint. Note that [Endpoint.traffic_split][google.cloud.aiplatform.v1beta1.Endpoint.traffic_split] must be updated for the DeployedModel to start receiving traffic, either as part of this call, or via [EndpointService.UpdateEndpoint][google.cloud.aiplatform.v1beta1.EndpointService.UpdateEndpoint]. This corresponds to the ``deployed_model`` field on the ``request`` instance; if ``request`` is provided, this should not be set. traffic_split (Sequence[google.cloud.aiplatform_v1beta1.types.DeployModelRequest.TrafficSplitEntry]): A map from a DeployedModel's ID to the percentage of this Endpoint's traffic that should be forwarded to that DeployedModel. If this field is non-empty, then the Endpoint's [traffic_split][google.cloud.aiplatform.v1beta1.Endpoint.traffic_split] will be overwritten with it. To refer to the ID of the just being deployed Model, a "0" should be used, and the actual ID of the new DeployedModel will be filled in its place by this method. The traffic percentage values must add up to 100. If this field is empty, then the Endpoint's [traffic_split][google.cloud.aiplatform.v1beta1.Endpoint.traffic_split] is not updated. This corresponds to the ``traffic_split`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: google.api_core.operation.Operation: An object representing a long-running operation. The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.DeployModelResponse` Response message for [EndpointService.DeployModel][google.cloud.aiplatform.v1beta1.EndpointService.DeployModel]. """ # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([endpoint, deployed_model, traffic_split]) if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." ) # Minor optimization to avoid making a copy if the user passes # in a endpoint_service.DeployModelRequest. # There's no risk of modifying the input as we've already verified # there are no flattened fields. if not isinstance(request, endpoint_service.DeployModelRequest): request = endpoint_service.DeployModelRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if endpoint is not None: request.endpoint = endpoint if deployed_model is not None: request.deployed_model = deployed_model if traffic_split is not None: request.traffic_split = traffic_split # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.deploy_model] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + ( gapic_v1.routing_header.to_grpc_metadata((("endpoint", request.endpoint),)), ) # Send the request. response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) # Wrap the response in an operation future. response = gac_operation.from_gapic( response, self._transport.operations_client, endpoint_service.DeployModelResponse, metadata_type=endpoint_service.DeployModelOperationMetadata, ) # Done; return the response. return response
async def deploy_model( self, request: endpoint_service.DeployModelRequest = None, *, endpoint: str = None, deployed_model: gca_endpoint.DeployedModel = None, traffic_split: Sequence[ endpoint_service.DeployModelRequest.TrafficSplitEntry] = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deploys a Model into this Endpoint, creating a DeployedModel within it. Args: request (:class:`~.endpoint_service.DeployModelRequest`): The request object. Request message for ``EndpointService.DeployModel``. endpoint (:class:`str`): Required. The name of the Endpoint resource into which to deploy a Model. Format: ``projects/{project}/locations/{location}/endpoints/{endpoint}`` This corresponds to the ``endpoint`` field on the ``request`` instance; if ``request`` is provided, this should not be set. deployed_model (:class:`~.gca_endpoint.DeployedModel`): Required. The DeployedModel to be created within the Endpoint. Note that ``Endpoint.traffic_split`` must be updated for the DeployedModel to start receiving traffic, either as part of this call, or via ``EndpointService.UpdateEndpoint``. This corresponds to the ``deployed_model`` field on the ``request`` instance; if ``request`` is provided, this should not be set. traffic_split (:class:`Sequence[~.endpoint_service.DeployModelRequest.TrafficSplitEntry]`): A map from a DeployedModel's ID to the percentage of this Endpoint's traffic that should be forwarded to that DeployedModel. If this field is non-empty, then the Endpoint's ``traffic_split`` will be overwritten with it. To refer to the ID of the just being deployed Model, a "0" should be used, and the actual ID of the new DeployedModel will be filled in its place by this method. The traffic percentage values must add up to 100. If this field is empty, then the Endpoint's ``traffic_split`` is not updated. This corresponds to the ``traffic_split`` field on the ``request`` instance; if ``request`` is provided, this should not be set. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. Returns: ~.operation_async.AsyncOperation: An object representing a long-running operation. The result type for the operation will be :class:`~.endpoint_service.DeployModelResponse`: Response message for ``EndpointService.DeployModel``. """ # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([endpoint, deployed_model, traffic_split]) if request is not None and has_flattened_params: raise ValueError("If the `request` argument is set, then none of " "the individual field arguments should be set.") request = endpoint_service.DeployModelRequest(request) # If we have keyword arguments corresponding to fields on the # request, apply these. if endpoint is not None: request.endpoint = endpoint if deployed_model is not None: request.deployed_model = deployed_model if traffic_split: request.traffic_split.update(traffic_split) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = gapic_v1.method_async.wrap_method( self._client._transport.deploy_model, default_timeout=None, client_info=DEFAULT_CLIENT_INFO, ) # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata( (("endpoint", request.endpoint), )), ) # Send the request. response = await rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Wrap the response in an operation future. response = operation_async.from_gapic( response, self._client._transport.operations_client, endpoint_service.DeployModelResponse, metadata_type=endpoint_service.DeployModelOperationMetadata, ) # Done; return the response. return response