Skip to content

Commit 9ef057a

Browse files
feat: add model_version_id to BatchPredictionJob in aiplatform v1 batch_prediction_job.proto (#1453)
* feat: add BatchImportModelEvaluationSlices API in aiplatform v1beta1 model_service.proto PiperOrigin-RevId: 456559576 Source-Link: googleapis/googleapis@f5cd509 Source-Link: googleapis/googleapis-gen@b3549d7 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjM1NDlkN2E2MjExNmQ1ZGJmNDllMjJmYjNkNGM3NTlkNWRhODMxMyJ9 * feat: add model_version_id to BatchPredictionJob in aiplatform v1 batch_prediction_job.proto feat: add model_version_id to DeployedModel in aiplatform v1 endpoint.proto feat: add model_version_id to PredictResponse in aiplatform v1 prediction_service.proto PiperOrigin-RevId: 456571762 Source-Link: googleapis/googleapis@19bd392 Source-Link: googleapis/googleapis-gen@d4dfc80 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDRkZmM4MDJhODhmZTc3YmMwNDE5MWY0YjFkOWI1OTQ4MWU2OTJmZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent d35df58 commit 9ef057a

22 files changed

+985
-50
lines changed

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -196,23 +196,18 @@ def parse_annotated_dataset_path(path: str) -> Dict[str, str]:
196196
@staticmethod
197197
def dataset_path(
198198
project: str,
199-
location: str,
200199
dataset: str,
201200
) -> str:
202201
"""Returns a fully-qualified dataset string."""
203-
return "projects/{project}/locations/{location}/datasets/{dataset}".format(
202+
return "projects/{project}/datasets/{dataset}".format(
204203
project=project,
205-
location=location,
206204
dataset=dataset,
207205
)
208206

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

218213
@staticmethod
@@ -240,18 +235,23 @@ def parse_dataset_path(path: str) -> Dict[str, str]:
240235
@staticmethod
241236
def dataset_path(
242237
project: str,
238+
location: str,
243239
dataset: str,
244240
) -> str:
245241
"""Returns a fully-qualified dataset string."""
246-
return "projects/{project}/datasets/{dataset}".format(
242+
return "projects/{project}/locations/{location}/datasets/{dataset}".format(
247243
project=project,
244+
location=location,
248245
dataset=dataset,
249246
)
250247

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

257257
@staticmethod

google/cloud/aiplatform_v1/types/batch_prediction_job.py

+7
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class BatchPredictionJob(proto.Message):
6666
The model resource name may contain version id or version
6767
alias to specify the version, if no version is specified,
6868
the default version will be used.
69+
model_version_id (str):
70+
Output only. The version ID of the Model that
71+
produces the predictions via this job.
6972
unmanaged_container_model (google.cloud.aiplatform_v1.types.UnmanagedContainerModel):
7073
Contains model information necessary to perform batch
7174
prediction without requiring uploading to model registry.
@@ -405,6 +408,10 @@ class OutputInfo(proto.Message):
405408
proto.STRING,
406409
number=3,
407410
)
411+
model_version_id = proto.Field(
412+
proto.STRING,
413+
number=30,
414+
)
408415
unmanaged_container_model = proto.Field(
409416
proto.MESSAGE,
410417
number=28,

google/cloud/aiplatform_v1/types/endpoint.py

+7
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ class DeployedModel(proto.Message):
229229
version alias to specify the version, if no
230230
version is specified, the default version will
231231
be deployed.
232+
model_version_id (str):
233+
Output only. The version ID of the model that
234+
is deployed.
232235
display_name (str):
233236
The display name of the DeployedModel. If not provided upon
234237
creation, the Model's display_name is used.
@@ -311,6 +314,10 @@ class DeployedModel(proto.Message):
311314
proto.STRING,
312315
number=2,
313316
)
317+
model_version_id = proto.Field(
318+
proto.STRING,
319+
number=18,
320+
)
314321
display_name = proto.Field(
315322
proto.STRING,
316323
number=3,

google/cloud/aiplatform_v1/types/prediction_service.py

+8
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ class PredictResponse(proto.Message):
9696
Output only. The resource name of the Model
9797
which is deployed as the DeployedModel that this
9898
prediction hits.
99+
model_version_id (str):
100+
Output only. The version ID of the Model
101+
which is deployed as the DeployedModel that this
102+
prediction hits.
99103
model_display_name (str):
100104
Output only. The [display
101105
name][google.cloud.aiplatform.v1.Model.display_name] of the
@@ -116,6 +120,10 @@ class PredictResponse(proto.Message):
116120
proto.STRING,
117121
number=3,
118122
)
123+
model_version_id = proto.Field(
124+
proto.STRING,
125+
number=5,
126+
)
119127
model_display_name = proto.Field(
120128
proto.STRING,
121129
number=4,

google/cloud/aiplatform_v1beta1/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@
348348
from .types.model_monitoring import ModelMonitoringObjectiveConfig
349349
from .types.model_monitoring import SamplingStrategy
350350
from .types.model_monitoring import ThresholdConfig
351+
from .types.model_service import BatchImportModelEvaluationSlicesRequest
352+
from .types.model_service import BatchImportModelEvaluationSlicesResponse
351353
from .types.model_service import DeleteModelRequest
352354
from .types.model_service import DeleteModelVersionRequest
353355
from .types.model_service import ExportModelOperationMetadata
@@ -541,6 +543,8 @@
541543
"BatchCreateTensorboardTimeSeriesRequest",
542544
"BatchCreateTensorboardTimeSeriesResponse",
543545
"BatchDedicatedResources",
546+
"BatchImportModelEvaluationSlicesRequest",
547+
"BatchImportModelEvaluationSlicesResponse",
544548
"BatchMigrateResourcesOperationMetadata",
545549
"BatchMigrateResourcesRequest",
546550
"BatchMigrateResourcesResponse",

google/cloud/aiplatform_v1beta1/gapic_metadata.json

+10
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,11 @@
12661266
"grpc": {
12671267
"libraryClient": "ModelServiceClient",
12681268
"rpcs": {
1269+
"BatchImportModelEvaluationSlices": {
1270+
"methods": [
1271+
"batch_import_model_evaluation_slices"
1272+
]
1273+
},
12691274
"DeleteModel": {
12701275
"methods": [
12711276
"delete_model"
@@ -1346,6 +1351,11 @@
13461351
"grpc-async": {
13471352
"libraryClient": "ModelServiceAsyncClient",
13481353
"rpcs": {
1354+
"BatchImportModelEvaluationSlices": {
1355+
"methods": [
1356+
"batch_import_model_evaluation_slices"
1357+
]
1358+
},
13491359
"DeleteModel": {
13501360
"methods": [
13511361
"delete_model"

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -196,40 +196,40 @@ def parse_annotated_dataset_path(path: str) -> Dict[str, str]:
196196
@staticmethod
197197
def dataset_path(
198198
project: str,
199+
location: str,
199200
dataset: str,
200201
) -> str:
201202
"""Returns a fully-qualified dataset string."""
202-
return "projects/{project}/datasets/{dataset}".format(
203+
return "projects/{project}/locations/{location}/datasets/{dataset}".format(
203204
project=project,
205+
location=location,
204206
dataset=dataset,
205207
)
206208

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

213218
@staticmethod
214219
def dataset_path(
215220
project: str,
216-
location: str,
217221
dataset: str,
218222
) -> str:
219223
"""Returns a fully-qualified dataset string."""
220-
return "projects/{project}/locations/{location}/datasets/{dataset}".format(
224+
return "projects/{project}/datasets/{dataset}".format(
221225
project=project,
222-
location=location,
223226
dataset=dataset,
224227
)
225228

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

235235
@staticmethod

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

+111
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,117 @@ async def sample_import_model_evaluation():
15391539
# Done; return the response.
15401540
return response
15411541

1542+
async def batch_import_model_evaluation_slices(
1543+
self,
1544+
request: Union[
1545+
model_service.BatchImportModelEvaluationSlicesRequest, dict
1546+
] = None,
1547+
*,
1548+
parent: str = None,
1549+
model_evaluation_slices: Sequence[
1550+
model_evaluation_slice.ModelEvaluationSlice
1551+
] = None,
1552+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1553+
timeout: float = None,
1554+
metadata: Sequence[Tuple[str, str]] = (),
1555+
) -> model_service.BatchImportModelEvaluationSlicesResponse:
1556+
r"""Imports a list of externally generated
1557+
ModelEvaluationSlice.
1558+
1559+
.. code-block:: python
1560+
1561+
from google.cloud import aiplatform_v1beta1
1562+
1563+
async def sample_batch_import_model_evaluation_slices():
1564+
# Create a client
1565+
client = aiplatform_v1beta1.ModelServiceAsyncClient()
1566+
1567+
# Initialize request argument(s)
1568+
request = aiplatform_v1beta1.BatchImportModelEvaluationSlicesRequest(
1569+
parent="parent_value",
1570+
)
1571+
1572+
# Make the request
1573+
response = await client.batch_import_model_evaluation_slices(request=request)
1574+
1575+
# Handle the response
1576+
print(response)
1577+
1578+
Args:
1579+
request (Union[google.cloud.aiplatform_v1beta1.types.BatchImportModelEvaluationSlicesRequest, dict]):
1580+
The request object. Request message for
1581+
[ModelService.BatchImportModelEvaluationSlices][google.cloud.aiplatform.v1beta1.ModelService.BatchImportModelEvaluationSlices]
1582+
parent (:class:`str`):
1583+
Required. The name of the parent ModelEvaluation
1584+
resource. Format:
1585+
``projects/{project}/locations/{location}/models/{model}/evaluations/{evaluation}``
1586+
1587+
This corresponds to the ``parent`` field
1588+
on the ``request`` instance; if ``request`` is provided, this
1589+
should not be set.
1590+
model_evaluation_slices (:class:`Sequence[google.cloud.aiplatform_v1beta1.types.ModelEvaluationSlice]`):
1591+
Required. Model evaluation slice
1592+
resource to be imported.
1593+
1594+
This corresponds to the ``model_evaluation_slices`` field
1595+
on the ``request`` instance; if ``request`` is provided, this
1596+
should not be set.
1597+
retry (google.api_core.retry.Retry): Designation of what errors, if any,
1598+
should be retried.
1599+
timeout (float): The timeout for this request.
1600+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1601+
sent along with the request as metadata.
1602+
1603+
Returns:
1604+
google.cloud.aiplatform_v1beta1.types.BatchImportModelEvaluationSlicesResponse:
1605+
Response message for
1606+
[ModelService.BatchImportModelEvaluationSlices][google.cloud.aiplatform.v1beta1.ModelService.BatchImportModelEvaluationSlices]
1607+
1608+
"""
1609+
# Create or coerce a protobuf request object.
1610+
# Quick check: If we got a request object, we should *not* have
1611+
# gotten any keyword arguments that map to the request.
1612+
has_flattened_params = any([parent, model_evaluation_slices])
1613+
if request is not None and has_flattened_params:
1614+
raise ValueError(
1615+
"If the `request` argument is set, then none of "
1616+
"the individual field arguments should be set."
1617+
)
1618+
1619+
request = model_service.BatchImportModelEvaluationSlicesRequest(request)
1620+
1621+
# If we have keyword arguments corresponding to fields on the
1622+
# request, apply these.
1623+
if parent is not None:
1624+
request.parent = parent
1625+
if model_evaluation_slices:
1626+
request.model_evaluation_slices.extend(model_evaluation_slices)
1627+
1628+
# Wrap the RPC method; this adds retry and timeout information,
1629+
# and friendly error handling.
1630+
rpc = gapic_v1.method_async.wrap_method(
1631+
self._client._transport.batch_import_model_evaluation_slices,
1632+
default_timeout=None,
1633+
client_info=DEFAULT_CLIENT_INFO,
1634+
)
1635+
1636+
# Certain fields should be provided within the metadata header;
1637+
# add these here.
1638+
metadata = tuple(metadata) + (
1639+
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
1640+
)
1641+
1642+
# Send the request.
1643+
response = await rpc(
1644+
request,
1645+
retry=retry,
1646+
timeout=timeout,
1647+
metadata=metadata,
1648+
)
1649+
1650+
# Done; return the response.
1651+
return response
1652+
15421653
async def get_model_evaluation(
15431654
self,
15441655
request: Union[model_service.GetModelEvaluationRequest, dict] = None,

0 commit comments

Comments
 (0)