GeezerVison is showing github.com — feat: add model_version_id to BatchPredictionJob in aiplatform v1 bat… · googleapis/python-aiplatform@9ef057a
File treeExpand file treeCollapse file tree Open diff view settings services/migration_service
samples/generated_samples
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/migration_service/client.py +9-9Lines changed: 9 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -196,23 +196,18 @@ def parse_annotated_dataset_path(path: str) -> Dict[str, str]: | 196 | 196 | @staticmethod | 197 | 197 | def dataset_path( | 198 | 198 | project: str, | 199 | | - location: str, | 200 | 199 | dataset: str, | 201 | 200 | ) -> str: | 202 | 201 | """Returns a fully-qualified dataset string.""" | 203 | | - return "projects/{project}/locations/{location}/datasets/{dataset}".format( | | 202 | + return "projects/{project}/datasets/{dataset}".format( | 204 | 203 | project=project, | 205 | | - location=location, | 206 | 204 | dataset=dataset, | 207 | 205 | ) | 208 | 206 |
| 209 | 207 | @staticmethod | 210 | 208 | def parse_dataset_path(path: str) -> Dict[str, str]: | 211 | 209 | """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) | 216 | 211 | return m.groupdict() if m else {} | 217 | 212 |
| 218 | 213 | @staticmethod | @@ -240,18 +235,23 @@ def parse_dataset_path(path: str) -> Dict[str, str]: | 240 | 235 | @staticmethod | 241 | 236 | def dataset_path( | 242 | 237 | project: str, | | 238 | + location: str, | 243 | 239 | dataset: str, | 244 | 240 | ) -> str: | 245 | 241 | """Returns a fully-qualified dataset string.""" | 246 | | - return "projects/{project}/datasets/{dataset}".format( | | 242 | + return "projects/{project}/locations/{location}/datasets/{dataset}".format( | 247 | 243 | project=project, | | 244 | + location=location, | 248 | 245 | dataset=dataset, | 249 | 246 | ) | 250 | 247 |
| 251 | 248 | @staticmethod | 252 | 249 | def parse_dataset_path(path: str) -> Dict[str, str]: | 253 | 250 | """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 | + ) | 255 | 255 | return m.groupdict() if m else {} | 256 | 256 |
| 257 | 257 | @staticmethod | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/types/batch_prediction_job.py +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -66,6 +66,9 @@ class BatchPredictionJob(proto.Message): | 66 | 66 | The model resource name may contain version id or version | 67 | 67 | alias to specify the version, if no version is specified, | 68 | 68 | 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. | 69 | 72 | unmanaged_container_model (google.cloud.aiplatform_v1.types.UnmanagedContainerModel): | 70 | 73 | Contains model information necessary to perform batch | 71 | 74 | prediction without requiring uploading to model registry. | @@ -405,6 +408,10 @@ class OutputInfo(proto.Message): | 405 | 408 | proto.STRING, | 406 | 409 | number=3, | 407 | 410 | ) | | 411 | + model_version_id = proto.Field( | | 412 | + proto.STRING, | | 413 | + number=30, | | 414 | + ) | 408 | 415 | unmanaged_container_model = proto.Field( | 409 | 416 | proto.MESSAGE, | 410 | 417 | number=28, | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/types/endpoint.py +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -229,6 +229,9 @@ class DeployedModel(proto.Message): | 229 | 229 | version alias to specify the version, if no | 230 | 230 | version is specified, the default version will | 231 | 231 | be deployed. | | 232 | + model_version_id (str): | | 233 | + Output only. The version ID of the model that | | 234 | + is deployed. | 232 | 235 | display_name (str): | 233 | 236 | The display name of the DeployedModel. If not provided upon | 234 | 237 | creation, the Model's display_name is used. | @@ -311,6 +314,10 @@ class DeployedModel(proto.Message): | 311 | 314 | proto.STRING, | 312 | 315 | number=2, | 313 | 316 | ) | | 317 | + model_version_id = proto.Field( | | 318 | + proto.STRING, | | 319 | + number=18, | | 320 | + ) | 314 | 321 | display_name = proto.Field( | 315 | 322 | proto.STRING, | 316 | 323 | number=3, | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/types/prediction_service.py +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -96,6 +96,10 @@ class PredictResponse(proto.Message): | 96 | 96 | Output only. The resource name of the Model | 97 | 97 | which is deployed as the DeployedModel that this | 98 | 98 | 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. | 99 | 103 | model_display_name (str): | 100 | 104 | Output only. The [display | 101 | 105 | name][google.cloud.aiplatform.v1.Model.display_name] of the | @@ -116,6 +120,10 @@ class PredictResponse(proto.Message): | 116 | 120 | proto.STRING, | 117 | 121 | number=3, | 118 | 122 | ) | | 123 | + model_version_id = proto.Field( | | 124 | + proto.STRING, | | 125 | + number=5, | | 126 | + ) | 119 | 127 | model_display_name = proto.Field( | 120 | 128 | proto.STRING, | 121 | 129 | number=4, | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1beta1/__init__.py +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 348 | 348 | from .types.model_monitoring import ModelMonitoringObjectiveConfig | 349 | 349 | from .types.model_monitoring import SamplingStrategy | 350 | 350 | from .types.model_monitoring import ThresholdConfig | | 351 | +from .types.model_service import BatchImportModelEvaluationSlicesRequest | | 352 | +from .types.model_service import BatchImportModelEvaluationSlicesResponse | 351 | 353 | from .types.model_service import DeleteModelRequest | 352 | 354 | from .types.model_service import DeleteModelVersionRequest | 353 | 355 | from .types.model_service import ExportModelOperationMetadata | | 541 | 543 | "BatchCreateTensorboardTimeSeriesRequest", | 542 | 544 | "BatchCreateTensorboardTimeSeriesResponse", | 543 | 545 | "BatchDedicatedResources", | | 546 | + "BatchImportModelEvaluationSlicesRequest", | | 547 | + "BatchImportModelEvaluationSlicesResponse", | 544 | 548 | "BatchMigrateResourcesOperationMetadata", | 545 | 549 | "BatchMigrateResourcesRequest", | 546 | 550 | "BatchMigrateResourcesResponse", | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1beta1/gapic_metadata.json +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1266 | 1266 | "grpc": { | 1267 | 1267 | "libraryClient": "ModelServiceClient", | 1268 | 1268 | "rpcs": { | | 1269 | + "BatchImportModelEvaluationSlices": { | | 1270 | + "methods": [ | | 1271 | + "batch_import_model_evaluation_slices" | | 1272 | + ] | | 1273 | + }, | 1269 | 1274 | "DeleteModel": { | 1270 | 1275 | "methods": [ | 1271 | 1276 | "delete_model" | | 1346 | 1351 | "grpc-async": { | 1347 | 1352 | "libraryClient": "ModelServiceAsyncClient", | 1348 | 1353 | "rpcs": { | | 1354 | + "BatchImportModelEvaluationSlices": { | | 1355 | + "methods": [ | | 1356 | + "batch_import_model_evaluation_slices" | | 1357 | + ] | | 1358 | + }, | 1349 | 1359 | "DeleteModel": { | 1350 | 1360 | "methods": [ | 1351 | 1361 | "delete_model" | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1beta1/services/migration_service/client.py +9-9Lines changed: 9 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -196,40 +196,40 @@ def parse_annotated_dataset_path(path: str) -> Dict[str, str]: | 196 | 196 | @staticmethod | 197 | 197 | def dataset_path( | 198 | 198 | project: str, | | 199 | + location: str, | 199 | 200 | dataset: str, | 200 | 201 | ) -> str: | 201 | 202 | """Returns a fully-qualified dataset string.""" | 202 | | - return "projects/{project}/datasets/{dataset}".format( | | 203 | + return "projects/{project}/locations/{location}/datasets/{dataset}".format( | 203 | 204 | project=project, | | 205 | + location=location, | 204 | 206 | dataset=dataset, | 205 | 207 | ) | 206 | 208 |
| 207 | 209 | @staticmethod | 208 | 210 | def parse_dataset_path(path: str) -> Dict[str, str]: | 209 | 211 | """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 | + ) | 211 | 216 | return m.groupdict() if m else {} | 212 | 217 |
| 213 | 218 | @staticmethod | 214 | 219 | def dataset_path( | 215 | 220 | project: str, | 216 | | - location: str, | 217 | 221 | dataset: str, | 218 | 222 | ) -> str: | 219 | 223 | """Returns a fully-qualified dataset string.""" | 220 | | - return "projects/{project}/locations/{location}/datasets/{dataset}".format( | | 224 | + return "projects/{project}/datasets/{dataset}".format( | 221 | 225 | project=project, | 222 | | - location=location, | 223 | 226 | dataset=dataset, | 224 | 227 | ) | 225 | 228 |
| 226 | 229 | @staticmethod | 227 | 230 | def parse_dataset_path(path: str) -> Dict[str, str]: | 228 | 231 | """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) | 233 | 233 | return m.groupdict() if m else {} | 234 | 234 |
| 235 | 235 | @staticmethod | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1beta1/services/model_service/async_client.py +111Lines changed: 111 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1539,6 +1539,117 @@ async def sample_import_model_evaluation(): | 1539 | 1539 | # Done; return the response. | 1540 | 1540 | return response | 1541 | 1541 |
| | 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 | + | 1542 | 1653 | async def get_model_evaluation( | 1543 | 1654 | self, | 1544 | 1655 | request: Union[model_service.GetModelEvaluationRequest, dict] = None, | |
|