GeezerVison is showing github.com — Copybara import of the project: · Ginx172/python-aiplatform@6a22bef
File treeExpand file treeCollapse file tree Open diff view settings services/schedule_service
samples/generated_samples
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | enabled: true | 2 | | -multiScmName: python-aiplatform |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/__init__.py +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 179 | 179 | ) | 180 | 180 | from .types.deployment_resource_pool_service import UpdateDeploymentResourcePoolRequest | 181 | 181 | from .types.encryption_spec import EncryptionSpec | | 182 | +from .types.endpoint import ClientConnectionConfig | 182 | 183 | from .types.endpoint import DeployedModel | 183 | 184 | from .types.endpoint import Endpoint | 184 | 185 | from .types.endpoint import FasterDeploymentConfig | | 199 | 200 | from .types.endpoint_service import UndeployModelOperationMetadata | 200 | 201 | from .types.endpoint_service import UndeployModelRequest | 201 | 202 | from .types.endpoint_service import UndeployModelResponse | | 203 | +from .types.endpoint_service import UpdateEndpointLongRunningRequest | | 204 | +from .types.endpoint_service import UpdateEndpointOperationMetadata | 202 | 205 | from .types.endpoint_service import UpdateEndpointRequest | 203 | 206 | from .types.entity_type import EntityType | 204 | 207 | from .types.env_var import EnvVar | | 1028 | 1031 | "CheckTrialEarlyStoppingStateResponse", | 1029 | 1032 | "Citation", | 1030 | 1033 | "CitationMetadata", | | 1034 | + "ClientConnectionConfig", | 1031 | 1035 | "CoherenceInput", | 1032 | 1036 | "CoherenceInstance", | 1033 | 1037 | "CoherenceResult", | | 1762 | 1766 | "UpdateDatasetVersionRequest", | 1763 | 1767 | "UpdateDeploymentResourcePoolOperationMetadata", | 1764 | 1768 | "UpdateDeploymentResourcePoolRequest", | | 1769 | + "UpdateEndpointLongRunningRequest", | | 1770 | + "UpdateEndpointOperationMetadata", | 1765 | 1771 | "UpdateEndpointRequest", | 1766 | 1772 | "UpdateEntityTypeRequest", | 1767 | 1773 | "UpdateExecutionRequest", | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/gapic_metadata.json +15Lines changed: 15 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 462 | 462 | "methods": [ | 463 | 463 | "update_endpoint" | 464 | 464 | ] | | 465 | + }, | | 466 | + "UpdateEndpointLongRunning": { | | 467 | + "methods": [ | | 468 | + "update_endpoint_long_running" | | 469 | + ] | 465 | 470 | } | 466 | 471 | } | 467 | 472 | }, | | 507 | 512 | "methods": [ | 508 | 513 | "update_endpoint" | 509 | 514 | ] | | 515 | + }, | | 516 | + "UpdateEndpointLongRunning": { | | 517 | + "methods": [ | | 518 | + "update_endpoint_long_running" | | 519 | + ] | 510 | 520 | } | 511 | 521 | } | 512 | 522 | }, | | 552 | 562 | "methods": [ | 553 | 563 | "update_endpoint" | 554 | 564 | ] | | 565 | + }, | | 566 | + "UpdateEndpointLongRunning": { | | 567 | + "methods": [ | | 568 | + "update_endpoint_long_running" | | 569 | + ] | 555 | 570 | } | 556 | 571 | } | 557 | 572 | } | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/endpoint_service/async_client.py +129Lines changed: 129 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -798,6 +798,135 @@ async def sample_update_endpoint(): | 798 | 798 | # Done; return the response. | 799 | 799 | return response | 800 | 800 |
| | 801 | + async def update_endpoint_long_running( | | 802 | + self, | | 803 | + request: Optional[ | | 804 | + Union[endpoint_service.UpdateEndpointLongRunningRequest, dict] | | 805 | + ] = None, | | 806 | + *, | | 807 | + endpoint: Optional[gca_endpoint.Endpoint] = None, | | 808 | + retry: OptionalRetry = gapic_v1.method.DEFAULT, | | 809 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, | | 810 | + metadata: Sequence[Tuple[str, str]] = (), | | 811 | + ) -> operation_async.AsyncOperation: | | 812 | + r"""Updates an Endpoint with a long running operation. | | 813 | +
| | 814 | + .. code-block:: python | | 815 | +
| | 816 | + # This snippet has been automatically generated and should be regarded as a | | 817 | + # code template only. | | 818 | + # It will require modifications to work: | | 819 | + # - It may require correct/in-range values for request initialization. | | 820 | + # - It may require specifying regional endpoints when creating the service | | 821 | + # client as shown in: | | 822 | + # https://googleapis.dev/python/google-api-core/latest/client_options.html | | 823 | + from google.cloud import aiplatform_v1 | | 824 | +
| | 825 | + async def sample_update_endpoint_long_running(): | | 826 | + # Create a client | | 827 | + client = aiplatform_v1.EndpointServiceAsyncClient() | | 828 | +
| | 829 | + # Initialize request argument(s) | | 830 | + endpoint = aiplatform_v1.Endpoint() | | 831 | + endpoint.display_name = "display_name_value" | | 832 | +
| | 833 | + request = aiplatform_v1.UpdateEndpointLongRunningRequest( | | 834 | + endpoint=endpoint, | | 835 | + ) | | 836 | +
| | 837 | + # Make the request | | 838 | + operation = client.update_endpoint_long_running(request=request) | | 839 | +
| | 840 | + print("Waiting for operation to complete...") | | 841 | +
| | 842 | + response = (await operation).result() | | 843 | +
| | 844 | + # Handle the response | | 845 | + print(response) | | 846 | +
| | 847 | + Args: | | 848 | + request (Optional[Union[google.cloud.aiplatform_v1.types.UpdateEndpointLongRunningRequest, dict]]): | | 849 | + The request object. Request message for | | 850 | + [EndpointService.UpdateEndpointLongRunning][google.cloud.aiplatform.v1.EndpointService.UpdateEndpointLongRunning]. | | 851 | + endpoint (:class:`google.cloud.aiplatform_v1.types.Endpoint`): | | 852 | + Required. The Endpoint which replaces the resource on | | 853 | + the server. Currently we only support updating the | | 854 | + ``client_connection_config`` field, all the other | | 855 | + fields' update will be blocked. | | 856 | +
| | 857 | + This corresponds to the ``endpoint`` field | | 858 | + on the ``request`` instance; if ``request`` is provided, this | | 859 | + should not be set. | | 860 | + retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, | | 861 | + should be retried. | | 862 | + timeout (float): The timeout for this request. | | 863 | + metadata (Sequence[Tuple[str, str]]): Strings which should be | | 864 | + sent along with the request as metadata. | | 865 | +
| | 866 | + Returns: | | 867 | + google.api_core.operation_async.AsyncOperation: | | 868 | + An object representing a long-running operation. | | 869 | +
| | 870 | + The result type for the operation will be :class:`google.cloud.aiplatform_v1.types.Endpoint` Models are deployed into it, and afterwards Endpoint is called to obtain | | 871 | + predictions and explanations. | | 872 | +
| | 873 | + """ | | 874 | + # Create or coerce a protobuf request object. | | 875 | + # - Quick check: If we got a request object, we should *not* have | | 876 | + # gotten any keyword arguments that map to the request. | | 877 | + has_flattened_params = any([endpoint]) | | 878 | + if request is not None and has_flattened_params: | | 879 | + raise ValueError( | | 880 | + "If the `request` argument is set, then none of " | | 881 | + "the individual field arguments should be set." | | 882 | + ) | | 883 | + | | 884 | + # - Use the request object if provided (there's no risk of modifying the input as | | 885 | + # there are no flattened fields), or create one. | | 886 | + if not isinstance(request, endpoint_service.UpdateEndpointLongRunningRequest): | | 887 | + request = endpoint_service.UpdateEndpointLongRunningRequest(request) | | 888 | + | | 889 | + # If we have keyword arguments corresponding to fields on the | | 890 | + # request, apply these. | | 891 | + if endpoint is not None: | | 892 | + request.endpoint = endpoint | | 893 | + | | 894 | + # Wrap the RPC method; this adds retry and timeout information, | | 895 | + # and friendly error handling. | | 896 | + rpc = self._client._transport._wrapped_methods[ | | 897 | + self._client._transport.update_endpoint_long_running | | 898 | + ] | | 899 | + | | 900 | + # Certain fields should be provided within the metadata header; | | 901 | + # add these here. | | 902 | + metadata = tuple(metadata) + ( | | 903 | + gapic_v1.routing_header.to_grpc_metadata( | | 904 | + (("endpoint.name", request.endpoint.name),) | | 905 | + ), | | 906 | + ) | | 907 | + | | 908 | + # Validate the universe domain. | | 909 | + self._client._validate_universe_domain() | | 910 | + | | 911 | + # Send the request. | | 912 | + response = await rpc( | | 913 | + request, | | 914 | + retry=retry, | | 915 | + timeout=timeout, | | 916 | + metadata=metadata, | | 917 | + ) | | 918 | + | | 919 | + # Wrap the response in an operation future. | | 920 | + response = operation_async.from_gapic( | | 921 | + response, | | 922 | + self._client._transport.operations_client, | | 923 | + gca_endpoint.Endpoint, | | 924 | + metadata_type=endpoint_service.UpdateEndpointOperationMetadata, | | 925 | + ) | | 926 | + | | 927 | + # Done; return the response. | | 928 | + return response | | 929 | + | 801 | 930 | async def delete_endpoint( | 802 | 931 | self, | 803 | 932 | request: Optional[Union[endpoint_service.DeleteEndpointRequest, dict]] = None, | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/endpoint_service/client.py +128Lines changed: 128 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1302,6 +1302,134 @@ def sample_update_endpoint(): | 1302 | 1302 | # Done; return the response. | 1303 | 1303 | return response | 1304 | 1304 |
| | 1305 | + def update_endpoint_long_running( | | 1306 | + self, | | 1307 | + request: Optional[ | | 1308 | + Union[endpoint_service.UpdateEndpointLongRunningRequest, dict] | | 1309 | + ] = None, | | 1310 | + *, | | 1311 | + endpoint: Optional[gca_endpoint.Endpoint] = None, | | 1312 | + retry: OptionalRetry = gapic_v1.method.DEFAULT, | | 1313 | + timeout: Union[float, object] = gapic_v1.method.DEFAULT, | | 1314 | + metadata: Sequence[Tuple[str, str]] = (), | | 1315 | + ) -> gac_operation.Operation: | | 1316 | + r"""Updates an Endpoint with a long running operation. | | 1317 | +
| | 1318 | + .. code-block:: python | | 1319 | +
| | 1320 | + # This snippet has been automatically generated and should be regarded as a | | 1321 | + # code template only. | | 1322 | + # It will require modifications to work: | | 1323 | + # - It may require correct/in-range values for request initialization. | | 1324 | + # - It may require specifying regional endpoints when creating the service | | 1325 | + # client as shown in: | | 1326 | + # https://googleapis.dev/python/google-api-core/latest/client_options.html | | 1327 | + from google.cloud import aiplatform_v1 | | 1328 | +
| | 1329 | + def sample_update_endpoint_long_running(): | | 1330 | + # Create a client | | 1331 | + client = aiplatform_v1.EndpointServiceClient() | | 1332 | +
| | 1333 | + # Initialize request argument(s) | | 1334 | + endpoint = aiplatform_v1.Endpoint() | | 1335 | + endpoint.display_name = "display_name_value" | | 1336 | +
| | 1337 | + request = aiplatform_v1.UpdateEndpointLongRunningRequest( | | 1338 | + endpoint=endpoint, | | 1339 | + ) | | 1340 | +
| | 1341 | + # Make the request | | 1342 | + operation = client.update_endpoint_long_running(request=request) | | 1343 | +
| | 1344 | + print("Waiting for operation to complete...") | | 1345 | +
| | 1346 | + response = operation.result() | | 1347 | +
| | 1348 | + # Handle the response | | 1349 | + print(response) | | 1350 | +
| | 1351 | + Args: | | 1352 | + request (Union[google.cloud.aiplatform_v1.types.UpdateEndpointLongRunningRequest, dict]): | | 1353 | + The request object. Request message for | | 1354 | + [EndpointService.UpdateEndpointLongRunning][google.cloud.aiplatform.v1.EndpointService.UpdateEndpointLongRunning]. | | 1355 | + endpoint (google.cloud.aiplatform_v1.types.Endpoint): | | 1356 | + Required. The Endpoint which replaces the resource on | | 1357 | + the server. Currently we only support updating the | | 1358 | + ``client_connection_config`` field, all the other | | 1359 | + fields' update will be blocked. | | 1360 | +
| | 1361 | + This corresponds to the ``endpoint`` field | | 1362 | + on the ``request`` instance; if ``request`` is provided, this | | 1363 | + should not be set. | | 1364 | + retry (google.api_core.retry.Retry): Designation of what errors, if any, | | 1365 | + should be retried. | | 1366 | + timeout (float): The timeout for this request. | | 1367 | + metadata (Sequence[Tuple[str, str]]): Strings which should be | | 1368 | + sent along with the request as metadata. | | 1369 | +
| | 1370 | + Returns: | | 1371 | + google.api_core.operation.Operation: | | 1372 | + An object representing a long-running operation. | | 1373 | +
| | 1374 | + The result type for the operation will be :class:`google.cloud.aiplatform_v1.types.Endpoint` Models are deployed into it, and afterwards Endpoint is called to obtain | | 1375 | + predictions and explanations. | | 1376 | +
| | 1377 | + """ | | 1378 | + # Create or coerce a protobuf request object. | | 1379 | + # - Quick check: If we got a request object, we should *not* have | | 1380 | + # gotten any keyword arguments that map to the request. | | 1381 | + has_flattened_params = any([endpoint]) | | 1382 | + if request is not None and has_flattened_params: | | 1383 | + raise ValueError( | | 1384 | + "If the `request` argument is set, then none of " | | 1385 | + "the individual field arguments should be set." | | 1386 | + ) | | 1387 | + | | 1388 | + # - Use the request object if provided (there's no risk of modifying the input as | | 1389 | + # there are no flattened fields), or create one. | | 1390 | + if not isinstance(request, endpoint_service.UpdateEndpointLongRunningRequest): | | 1391 | + request = endpoint_service.UpdateEndpointLongRunningRequest(request) | | 1392 | + # If we have keyword arguments corresponding to fields on the | | 1393 | + # request, apply these. | | 1394 | + if endpoint is not None: | | 1395 | + request.endpoint = endpoint | | 1396 | + | | 1397 | + # Wrap the RPC method; this adds retry and timeout information, | | 1398 | + # and friendly error handling. | | 1399 | + rpc = self._transport._wrapped_methods[ | | 1400 | + self._transport.update_endpoint_long_running | | 1401 | + ] | | 1402 | + | | 1403 | + # Certain fields should be provided within the metadata header; | | 1404 | + # add these here. | | 1405 | + metadata = tuple(metadata) + ( | | 1406 | + gapic_v1.routing_header.to_grpc_metadata( | | 1407 | + (("endpoint.name", request.endpoint.name),) | | 1408 | + ), | | 1409 | + ) | | 1410 | + | | 1411 | + # Validate the universe domain. | | 1412 | + self._validate_universe_domain() | | 1413 | + | | 1414 | + # Send the request. | | 1415 | + response = rpc( | | 1416 | + request, | | 1417 | + retry=retry, | | 1418 | + timeout=timeout, | | 1419 | + metadata=metadata, | | 1420 | + ) | | 1421 | + | | 1422 | + # Wrap the response in an operation future. | | 1423 | + response = gac_operation.from_gapic( | | 1424 | + response, | | 1425 | + self._transport.operations_client, | | 1426 | + gca_endpoint.Endpoint, | | 1427 | + metadata_type=endpoint_service.UpdateEndpointOperationMetadata, | | 1428 | + ) | | 1429 | + | | 1430 | + # Done; return the response. | | 1431 | + return response | | 1432 | + | 1305 | 1433 | def delete_endpoint( | 1306 | 1434 | self, | 1307 | 1435 | request: Optional[Union[endpoint_service.DeleteEndpointRequest, dict]] = None, | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/endpoint_service/transports/base.py +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -156,6 +156,11 @@ def _prep_wrapped_messages(self, client_info): | 156 | 156 | default_timeout=None, | 157 | 157 | client_info=client_info, | 158 | 158 | ), | | 159 | + self.update_endpoint_long_running: gapic_v1.method.wrap_method( | | 160 | + self.update_endpoint_long_running, | | 161 | + default_timeout=None, | | 162 | + client_info=client_info, | | 163 | + ), | 159 | 164 | self.delete_endpoint: gapic_v1.method.wrap_method( | 160 | 165 | self.delete_endpoint, | 161 | 166 | default_timeout=None, | @@ -281,6 +286,15 @@ def update_endpoint( | 281 | 286 | ]: | 282 | 287 | raise NotImplementedError() | 283 | 288 |
| | 289 | + @property | | 290 | + def update_endpoint_long_running( | | 291 | + self, | | 292 | + ) -> Callable[ | | 293 | + [endpoint_service.UpdateEndpointLongRunningRequest], | | 294 | + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], | | 295 | + ]: | | 296 | + raise NotImplementedError() | | 297 | + | 284 | 298 | @property | 285 | 299 | def delete_endpoint( | 286 | 300 | self, | |
|