GeezerVison is showing github.com — Copybara import of the project: · Russ76/python-aiplatform@6720dd1
File treeExpand file treeCollapse file tree Open diff view settings featurestore_online_serving_service
samples/generated_samples
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings 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 |
|---|
| 142 | 142 | from .types.featurestore_online_service import ReadFeatureValuesRequest | 143 | 143 | from .types.featurestore_online_service import ReadFeatureValuesResponse | 144 | 144 | from .types.featurestore_online_service import StreamingReadFeatureValuesRequest | | 145 | +from .types.featurestore_online_service import WriteFeatureValuesPayload | | 146 | +from .types.featurestore_online_service import WriteFeatureValuesRequest | | 147 | +from .types.featurestore_online_service import WriteFeatureValuesResponse | 145 | 148 | from .types.featurestore_service import BatchCreateFeaturesOperationMetadata | 146 | 149 | from .types.featurestore_service import BatchCreateFeaturesRequest | 147 | 150 | from .types.featurestore_service import BatchCreateFeaturesResponse | | 986 | 989 | "Value", | 987 | 990 | "VizierServiceClient", | 988 | 991 | "WorkerPoolSpec", | | 992 | + "WriteFeatureValuesPayload", | | 993 | + "WriteFeatureValuesRequest", | | 994 | + "WriteFeatureValuesResponse", | 989 | 995 | "WriteTensorboardExperimentDataRequest", | 990 | 996 | "WriteTensorboardExperimentDataResponse", | 991 | 997 | "WriteTensorboardRunDataRequest", | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/gapic_metadata.json +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 227 | 227 | "methods": [ | 228 | 228 | "streaming_read_feature_values" | 229 | 229 | ] | | 230 | + }, | | 231 | + "WriteFeatureValues": { | | 232 | + "methods": [ | | 233 | + "write_feature_values" | | 234 | + ] | 230 | 235 | } | 231 | 236 | } | 232 | 237 | }, | | 242 | 247 | "methods": [ | 243 | 248 | "streaming_read_feature_values" | 244 | 249 | ] | | 250 | + }, | | 251 | + "WriteFeatureValues": { | | 252 | + "methods": [ | | 253 | + "write_feature_values" | | 254 | + ] | 245 | 255 | } | 246 | 256 | } | 247 | 257 | } | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/featurestore_online_serving_service/async_client.py +130Lines changed: 130 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -471,6 +471,136 @@ async def sample_streaming_read_feature_values(): | 471 | 471 | # Done; return the response. | 472 | 472 | return response | 473 | 473 |
| | 474 | + async def write_feature_values( | | 475 | + self, | | 476 | + request: Union[ | | 477 | + featurestore_online_service.WriteFeatureValuesRequest, dict | | 478 | + ] = None, | | 479 | + *, | | 480 | + entity_type: str = None, | | 481 | + payloads: Sequence[ | | 482 | + featurestore_online_service.WriteFeatureValuesPayload | | 483 | + ] = None, | | 484 | + retry: OptionalRetry = gapic_v1.method.DEFAULT, | | 485 | + timeout: float = None, | | 486 | + metadata: Sequence[Tuple[str, str]] = (), | | 487 | + ) -> featurestore_online_service.WriteFeatureValuesResponse: | | 488 | + r"""Writes Feature values of one or more entities of an | | 489 | + EntityType. | | 490 | + The Feature values are merged into existing entities if | | 491 | + any. The Feature values to be written must have | | 492 | + timestamp within the online storage retention. | | 493 | +
| | 494 | + .. code-block:: python | | 495 | +
| | 496 | + # This snippet has been automatically generated and should be regarded as a | | 497 | + # code template only. | | 498 | + # It will require modifications to work: | | 499 | + # - It may require correct/in-range values for request initialization. | | 500 | + # - It may require specifying regional endpoints when creating the service | | 501 | + # client as shown in: | | 502 | + # https://googleapis.dev/python/google-api-core/latest/client_options.html | | 503 | + from google.cloud import aiplatform_v1 | | 504 | +
| | 505 | + async def sample_write_feature_values(): | | 506 | + # Create a client | | 507 | + client = aiplatform_v1.FeaturestoreOnlineServingServiceAsyncClient() | | 508 | +
| | 509 | + # Initialize request argument(s) | | 510 | + payloads = aiplatform_v1.WriteFeatureValuesPayload() | | 511 | + payloads.entity_id = "entity_id_value" | | 512 | +
| | 513 | + request = aiplatform_v1.WriteFeatureValuesRequest( | | 514 | + entity_type="entity_type_value", | | 515 | + payloads=payloads, | | 516 | + ) | | 517 | +
| | 518 | + # Make the request | | 519 | + response = await client.write_feature_values(request=request) | | 520 | +
| | 521 | + # Handle the response | | 522 | + print(response) | | 523 | +
| | 524 | + Args: | | 525 | + request (Union[google.cloud.aiplatform_v1.types.WriteFeatureValuesRequest, dict]): | | 526 | + The request object. Request message for | | 527 | + [FeaturestoreOnlineServingService.WriteFeatureValues][google.cloud.aiplatform.v1.FeaturestoreOnlineServingService.WriteFeatureValues]. | | 528 | + entity_type (:class:`str`): | | 529 | + Required. The resource name of the EntityType for the | | 530 | + entities being written. Value format: | | 531 | + ``projects/{project}/locations/{location}/featurestores/ {featurestore}/entityTypes/{entityType}``. | | 532 | + For example, for a machine learning model predicting | | 533 | + user clicks on a website, an EntityType ID could be | | 534 | + ``user``. | | 535 | +
| | 536 | + This corresponds to the ``entity_type`` field | | 537 | + on the ``request`` instance; if ``request`` is provided, this | | 538 | + should not be set. | | 539 | + payloads (:class:`Sequence[google.cloud.aiplatform_v1.types.WriteFeatureValuesPayload]`): | | 540 | + Required. The entities to be written. Up to 100,000 | | 541 | + feature values can be written across all ``payloads``. | | 542 | +
| | 543 | + This corresponds to the ``payloads`` field | | 544 | + on the ``request`` instance; if ``request`` is provided, this | | 545 | + should not be set. | | 546 | + retry (google.api_core.retry.Retry): Designation of what errors, if any, | | 547 | + should be retried. | | 548 | + timeout (float): The timeout for this request. | | 549 | + metadata (Sequence[Tuple[str, str]]): Strings which should be | | 550 | + sent along with the request as metadata. | | 551 | +
| | 552 | + Returns: | | 553 | + google.cloud.aiplatform_v1.types.WriteFeatureValuesResponse: | | 554 | + Response message for | | 555 | + [FeaturestoreOnlineServingService.WriteFeatureValues][google.cloud.aiplatform.v1.FeaturestoreOnlineServingService.WriteFeatureValues]. | | 556 | +
| | 557 | + """ | | 558 | + # Create or coerce a protobuf request object. | | 559 | + # Quick check: If we got a request object, we should *not* have | | 560 | + # gotten any keyword arguments that map to the request. | | 561 | + has_flattened_params = any([entity_type, payloads]) | | 562 | + if request is not None and has_flattened_params: | | 563 | + raise ValueError( | | 564 | + "If the `request` argument is set, then none of " | | 565 | + "the individual field arguments should be set." | | 566 | + ) | | 567 | + | | 568 | + request = featurestore_online_service.WriteFeatureValuesRequest(request) | | 569 | + | | 570 | + # If we have keyword arguments corresponding to fields on the | | 571 | + # request, apply these. | | 572 | + if entity_type is not None: | | 573 | + request.entity_type = entity_type | | 574 | + if payloads: | | 575 | + request.payloads.extend(payloads) | | 576 | + | | 577 | + # Wrap the RPC method; this adds retry and timeout information, | | 578 | + # and friendly error handling. | | 579 | + rpc = gapic_v1.method_async.wrap_method( | | 580 | + self._client._transport.write_feature_values, | | 581 | + default_timeout=None, | | 582 | + client_info=DEFAULT_CLIENT_INFO, | | 583 | + ) | | 584 | + | | 585 | + # Certain fields should be provided within the metadata header; | | 586 | + # add these here. | | 587 | + metadata = tuple(metadata) + ( | | 588 | + gapic_v1.routing_header.to_grpc_metadata( | | 589 | + (("entity_type", request.entity_type),) | | 590 | + ), | | 591 | + ) | | 592 | + | | 593 | + # Send the request. | | 594 | + response = await rpc( | | 595 | + request, | | 596 | + retry=retry, | | 597 | + timeout=timeout, | | 598 | + metadata=metadata, | | 599 | + ) | | 600 | + | | 601 | + # Done; return the response. | | 602 | + return response | | 603 | + | 474 | 604 | async def list_operations( | 475 | 605 | self, | 476 | 606 | request: operations_pb2.ListOperationsRequest = None, | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/featurestore_online_serving_service/client.py +132Lines changed: 132 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -685,6 +685,138 @@ def sample_streaming_read_feature_values(): | 685 | 685 | # Done; return the response. | 686 | 686 | return response | 687 | 687 |
| | 688 | + def write_feature_values( | | 689 | + self, | | 690 | + request: Union[ | | 691 | + featurestore_online_service.WriteFeatureValuesRequest, dict | | 692 | + ] = None, | | 693 | + *, | | 694 | + entity_type: str = None, | | 695 | + payloads: Sequence[ | | 696 | + featurestore_online_service.WriteFeatureValuesPayload | | 697 | + ] = None, | | 698 | + retry: OptionalRetry = gapic_v1.method.DEFAULT, | | 699 | + timeout: float = None, | | 700 | + metadata: Sequence[Tuple[str, str]] = (), | | 701 | + ) -> featurestore_online_service.WriteFeatureValuesResponse: | | 702 | + r"""Writes Feature values of one or more entities of an | | 703 | + EntityType. | | 704 | + The Feature values are merged into existing entities if | | 705 | + any. The Feature values to be written must have | | 706 | + timestamp within the online storage retention. | | 707 | +
| | 708 | + .. code-block:: python | | 709 | +
| | 710 | + # This snippet has been automatically generated and should be regarded as a | | 711 | + # code template only. | | 712 | + # It will require modifications to work: | | 713 | + # - It may require correct/in-range values for request initialization. | | 714 | + # - It may require specifying regional endpoints when creating the service | | 715 | + # client as shown in: | | 716 | + # https://googleapis.dev/python/google-api-core/latest/client_options.html | | 717 | + from google.cloud import aiplatform_v1 | | 718 | +
| | 719 | + def sample_write_feature_values(): | | 720 | + # Create a client | | 721 | + client = aiplatform_v1.FeaturestoreOnlineServingServiceClient() | | 722 | +
| | 723 | + # Initialize request argument(s) | | 724 | + payloads = aiplatform_v1.WriteFeatureValuesPayload() | | 725 | + payloads.entity_id = "entity_id_value" | | 726 | +
| | 727 | + request = aiplatform_v1.WriteFeatureValuesRequest( | | 728 | + entity_type="entity_type_value", | | 729 | + payloads=payloads, | | 730 | + ) | | 731 | +
| | 732 | + # Make the request | | 733 | + response = client.write_feature_values(request=request) | | 734 | +
| | 735 | + # Handle the response | | 736 | + print(response) | | 737 | +
| | 738 | + Args: | | 739 | + request (Union[google.cloud.aiplatform_v1.types.WriteFeatureValuesRequest, dict]): | | 740 | + The request object. Request message for | | 741 | + [FeaturestoreOnlineServingService.WriteFeatureValues][google.cloud.aiplatform.v1.FeaturestoreOnlineServingService.WriteFeatureValues]. | | 742 | + entity_type (str): | | 743 | + Required. The resource name of the EntityType for the | | 744 | + entities being written. Value format: | | 745 | + ``projects/{project}/locations/{location}/featurestores/ {featurestore}/entityTypes/{entityType}``. | | 746 | + For example, for a machine learning model predicting | | 747 | + user clicks on a website, an EntityType ID could be | | 748 | + ``user``. | | 749 | +
| | 750 | + This corresponds to the ``entity_type`` field | | 751 | + on the ``request`` instance; if ``request`` is provided, this | | 752 | + should not be set. | | 753 | + payloads (Sequence[google.cloud.aiplatform_v1.types.WriteFeatureValuesPayload]): | | 754 | + Required. The entities to be written. Up to 100,000 | | 755 | + feature values can be written across all ``payloads``. | | 756 | +
| | 757 | + This corresponds to the ``payloads`` field | | 758 | + on the ``request`` instance; if ``request`` is provided, this | | 759 | + should not be set. | | 760 | + retry (google.api_core.retry.Retry): Designation of what errors, if any, | | 761 | + should be retried. | | 762 | + timeout (float): The timeout for this request. | | 763 | + metadata (Sequence[Tuple[str, str]]): Strings which should be | | 764 | + sent along with the request as metadata. | | 765 | +
| | 766 | + Returns: | | 767 | + google.cloud.aiplatform_v1.types.WriteFeatureValuesResponse: | | 768 | + Response message for | | 769 | + [FeaturestoreOnlineServingService.WriteFeatureValues][google.cloud.aiplatform.v1.FeaturestoreOnlineServingService.WriteFeatureValues]. | | 770 | +
| | 771 | + """ | | 772 | + # Create or coerce a protobuf request object. | | 773 | + # Quick check: If we got a request object, we should *not* have | | 774 | + # gotten any keyword arguments that map to the request. | | 775 | + has_flattened_params = any([entity_type, payloads]) | | 776 | + if request is not None and has_flattened_params: | | 777 | + raise ValueError( | | 778 | + "If the `request` argument is set, then none of " | | 779 | + "the individual field arguments should be set." | | 780 | + ) | | 781 | + | | 782 | + # Minor optimization to avoid making a copy if the user passes | | 783 | + # in a featurestore_online_service.WriteFeatureValuesRequest. | | 784 | + # There's no risk of modifying the input as we've already verified | | 785 | + # there are no flattened fields. | | 786 | + if not isinstance( | | 787 | + request, featurestore_online_service.WriteFeatureValuesRequest | | 788 | + ): | | 789 | + request = featurestore_online_service.WriteFeatureValuesRequest(request) | | 790 | + # If we have keyword arguments corresponding to fields on the | | 791 | + # request, apply these. | | 792 | + if entity_type is not None: | | 793 | + request.entity_type = entity_type | | 794 | + if payloads is not None: | | 795 | + request.payloads = payloads | | 796 | + | | 797 | + # Wrap the RPC method; this adds retry and timeout information, | | 798 | + # and friendly error handling. | | 799 | + rpc = self._transport._wrapped_methods[self._transport.write_feature_values] | | 800 | + | | 801 | + # Certain fields should be provided within the metadata header; | | 802 | + # add these here. | | 803 | + metadata = tuple(metadata) + ( | | 804 | + gapic_v1.routing_header.to_grpc_metadata( | | 805 | + (("entity_type", request.entity_type),) | | 806 | + ), | | 807 | + ) | | 808 | + | | 809 | + # Send the request. | | 810 | + response = rpc( | | 811 | + request, | | 812 | + retry=retry, | | 813 | + timeout=timeout, | | 814 | + metadata=metadata, | | 815 | + ) | | 816 | + | | 817 | + # Done; return the response. | | 818 | + return response | | 819 | + | 688 | 820 | def __enter__(self): | 689 | 821 | return self | 690 | 822 |
| |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/featurestore_online_serving_service/transports/base.py +17Lines changed: 17 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -141,6 +141,11 @@ def _prep_wrapped_messages(self, client_info): | 141 | 141 | default_timeout=None, | 142 | 142 | client_info=client_info, | 143 | 143 | ), | | 144 | + self.write_feature_values: gapic_v1.method.wrap_method( | | 145 | + self.write_feature_values, | | 146 | + default_timeout=None, | | 147 | + client_info=client_info, | | 148 | + ), | 144 | 149 | } | 145 | 150 |
| 146 | 151 | def close(self): | @@ -176,6 +181,18 @@ def streaming_read_feature_values( | 176 | 181 | ]: | 177 | 182 | raise NotImplementedError() | 178 | 183 |
| | 184 | + @property | | 185 | + def write_feature_values( | | 186 | + self, | | 187 | + ) -> Callable[ | | 188 | + [featurestore_online_service.WriteFeatureValuesRequest], | | 189 | + Union[ | | 190 | + featurestore_online_service.WriteFeatureValuesResponse, | | 191 | + Awaitable[featurestore_online_service.WriteFeatureValuesResponse], | | 192 | + ], | | 193 | + ]: | | 194 | + raise NotImplementedError() | | 195 | + | 179 | 196 | @property | 180 | 197 | def list_operations( | 181 | 198 | self, | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/aiplatform_v1/services/featurestore_online_serving_service/transports/grpc.py +33Lines changed: 33 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -300,6 +300,39 @@ def streaming_read_feature_values( | 300 | 300 | ) | 301 | 301 | return self._stubs["streaming_read_feature_values"] | 302 | 302 |
| | 303 | + @property | | 304 | + def write_feature_values( | | 305 | + self, | | 306 | + ) -> Callable[ | | 307 | + [featurestore_online_service.WriteFeatureValuesRequest], | | 308 | + featurestore_online_service.WriteFeatureValuesResponse, | | 309 | + ]: | | 310 | + r"""Return a callable for the write feature values method over gRPC. | | 311 | +
| | 312 | + Writes Feature values of one or more entities of an | | 313 | + EntityType. | | 314 | + The Feature values are merged into existing entities if | | 315 | + any. The Feature values to be written must have | | 316 | + timestamp within the online storage retention. | | 317 | +
| | 318 | + Returns: | | 319 | + Callable[[~.WriteFeatureValuesRequest], | | 320 | + ~.WriteFeatureValuesResponse]: | | 321 | + A function that, when called, will call the underlying RPC | | 322 | + on the server. | | 323 | + """ | | 324 | + # Generate a "stub function" on-the-fly which will actually make | | 325 | + # the request. | | 326 | + # gRPC handles serialization and deserialization, so we just need | | 327 | + # to pass in the functions for each. | | 328 | + if "write_feature_values" not in self._stubs: | | 329 | + self._stubs["write_feature_values"] = self.grpc_channel.unary_unary( | | 330 | + "/google.cloud.aiplatform.v1.FeaturestoreOnlineServingService/WriteFeatureValues", | | 331 | + request_serializer=featurestore_online_service.WriteFeatureValuesRequest.serialize, | | 332 | + response_deserializer=featurestore_online_service.WriteFeatureValuesResponse.deserialize, | | 333 | + ) | | 334 | + return self._stubs["write_feature_values"] | | 335 | + | 303 | 336 | def close(self): | 304 | 337 | self.grpc_channel.close() | 305 | 338 |
| |
|