Skip to content

Commit

Permalink
feat: add a new thought field in content proto
Browse files Browse the repository at this point in the history
feat: add Model Garden deploy API
docs: A comment for field `labels` in message `.google.cloud.aiplatform.v1beta1.PublisherModel` is changed

COPYBARA_INTEGRATE_REVIEW=#4795 from googleapis:owl-bot-copy cb74124
PiperOrigin-RevId: 711486245
  • Loading branch information
gcf-owl-bot[bot] authored and copybara-github committed Jan 2, 2025
1 parent 1eb493b commit 67358fa
Show file tree
Hide file tree
Showing 22 changed files with 6,681 additions and 286 deletions.
6 changes: 6 additions & 0 deletions google/cloud/aiplatform_v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,9 @@
)
from .types.model_evaluation import ModelEvaluation
from .types.model_evaluation_slice import ModelEvaluationSlice
from .types.model_garden_service import DeployPublisherModelOperationMetadata
from .types.model_garden_service import DeployPublisherModelRequest
from .types.model_garden_service import DeployPublisherModelResponse
from .types.model_garden_service import GetPublisherModelRequest
from .types.model_garden_service import ListPublisherModelsRequest
from .types.model_garden_service import ListPublisherModelsResponse
Expand Down Expand Up @@ -1411,6 +1414,9 @@
"DeployModelOperationMetadata",
"DeployModelRequest",
"DeployModelResponse",
"DeployPublisherModelOperationMetadata",
"DeployPublisherModelRequest",
"DeployPublisherModelResponse",
"DeployedIndex",
"DeployedIndexAuthConfig",
"DeployedIndexRef",
Expand Down
15 changes: 15 additions & 0 deletions google/cloud/aiplatform_v1beta1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3345,6 +3345,11 @@
"grpc": {
"libraryClient": "ModelGardenServiceClient",
"rpcs": {
"DeployPublisherModel": {
"methods": [
"deploy_publisher_model"
]
},
"GetPublisherModel": {
"methods": [
"get_publisher_model"
Expand All @@ -3360,6 +3365,11 @@
"grpc-async": {
"libraryClient": "ModelGardenServiceAsyncClient",
"rpcs": {
"DeployPublisherModel": {
"methods": [
"deploy_publisher_model"
]
},
"GetPublisherModel": {
"methods": [
"get_publisher_model"
Expand All @@ -3375,6 +3385,11 @@
"rest": {
"libraryClient": "ModelGardenServiceClient",
"rpcs": {
"DeployPublisherModel": {
"methods": [
"deploy_publisher_model"
]
},
"GetPublisherModel": {
"methods": [
"get_publisher_model"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,23 @@ def parse_annotated_dataset_path(path: str) -> Dict[str, str]:
@staticmethod
def dataset_path(
project: str,
location: str,
dataset: str,
) -> str:
"""Returns a fully-qualified dataset string."""
return "projects/{project}/datasets/{dataset}".format(
return "projects/{project}/locations/{location}/datasets/{dataset}".format(
project=project,
location=location,
dataset=dataset,
)

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

@staticmethod
Expand Down Expand Up @@ -279,23 +284,18 @@ def parse_dataset_path(path: str) -> Dict[str, str]:
@staticmethod
def dataset_path(
project: str,
location: str,
dataset: str,
) -> str:
"""Returns a fully-qualified dataset string."""
return "projects/{project}/locations/{location}/datasets/{dataset}".format(
return "projects/{project}/datasets/{dataset}".format(
project=project,
location=location,
dataset=dataset,
)

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

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.AsyncRetry, object, None] # type: ignore

from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.aiplatform_v1beta1.services.model_garden_service import pagers
from google.cloud.aiplatform_v1beta1.types import model
from google.cloud.aiplatform_v1beta1.types import model_garden_service
Expand Down Expand Up @@ -78,6 +80,10 @@ class ModelGardenServiceAsyncClient:
_DEFAULT_ENDPOINT_TEMPLATE = ModelGardenServiceClient._DEFAULT_ENDPOINT_TEMPLATE
_DEFAULT_UNIVERSE = ModelGardenServiceClient._DEFAULT_UNIVERSE

endpoint_path = staticmethod(ModelGardenServiceClient.endpoint_path)
parse_endpoint_path = staticmethod(ModelGardenServiceClient.parse_endpoint_path)
model_path = staticmethod(ModelGardenServiceClient.model_path)
parse_model_path = staticmethod(ModelGardenServiceClient.parse_model_path)
publisher_model_path = staticmethod(ModelGardenServiceClient.publisher_model_path)
parse_publisher_model_path = staticmethod(
ModelGardenServiceClient.parse_publisher_model_path
Expand Down Expand Up @@ -536,6 +542,111 @@ async def sample_list_publisher_models():
# Done; return the response.
return response

async def deploy_publisher_model(
self,
request: Optional[
Union[model_garden_service.DeployPublisherModelRequest, dict]
] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> operation_async.AsyncOperation:
r"""Deploys publisher models.
.. code-block:: python
# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import aiplatform_v1beta1
async def sample_deploy_publisher_model():
# Create a client
client = aiplatform_v1beta1.ModelGardenServiceAsyncClient()
# Initialize request argument(s)
request = aiplatform_v1beta1.DeployPublisherModelRequest(
model="model_value",
destination="destination_value",
)
# Make the request
operation = client.deploy_publisher_model(request=request)
print("Waiting for operation to complete...")
response = (await operation).result()
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.aiplatform_v1beta1.types.DeployPublisherModelRequest, dict]]):
The request object. Request message for
[ModelGardenService.DeployPublisherModel][google.cloud.aiplatform.v1beta1.ModelGardenService.DeployPublisherModel].
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
sent along with the request as metadata. Normally, each value must be of type `str`,
but for metadata keys ending with the suffix `-bin`, the corresponding values must
be of type `bytes`.
Returns:
google.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.
The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.DeployPublisherModelResponse` Response message for
[ModelGardenService.DeployPublisherModel][google.cloud.aiplatform.v1beta1.ModelGardenService.DeployPublisherModel].
"""
# Create or coerce a protobuf request object.
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, model_garden_service.DeployPublisherModelRequest):
request = model_garden_service.DeployPublisherModelRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.deploy_publisher_model
]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("destination", request.destination),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# 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,
model_garden_service.DeployPublisherModelResponse,
metadata_type=model_garden_service.DeployPublisherModelOperationMetadata,
)

# Done; return the response.
return response

async def list_operations(
self,
request: Optional[operations_pb2.ListOperationsRequest] = None,
Expand Down
Loading

0 comments on commit 67358fa

Please sign in to comment.