Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add read_mask to ListPipelineJobsRequest in aiplatform v1 pipeline_service #1589

Merged
merged 18 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions google/cloud/aiplatform_v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@
from .types.featurestore_online_service import ReadFeatureValuesRequest
from .types.featurestore_online_service import ReadFeatureValuesResponse
from .types.featurestore_online_service import StreamingReadFeatureValuesRequest
from .types.featurestore_online_service import WriteFeatureValuesPayload
from .types.featurestore_online_service import WriteFeatureValuesRequest
from .types.featurestore_online_service import WriteFeatureValuesResponse
from .types.featurestore_service import BatchCreateFeaturesOperationMetadata
from .types.featurestore_service import BatchCreateFeaturesRequest
from .types.featurestore_service import BatchCreateFeaturesResponse
Expand Down Expand Up @@ -1012,6 +1015,9 @@
"Value",
"VizierServiceClient",
"WorkerPoolSpec",
"WriteFeatureValuesPayload",
"WriteFeatureValuesRequest",
"WriteFeatureValuesResponse",
"WriteTensorboardExperimentDataRequest",
"WriteTensorboardExperimentDataResponse",
"WriteTensorboardRunDataRequest",
Expand Down
10 changes: 10 additions & 0 deletions google/cloud/aiplatform_v1beta1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@
"methods": [
"streaming_read_feature_values"
]
},
"WriteFeatureValues": {
"methods": [
"write_feature_values"
]
}
}
},
Expand All @@ -306,6 +311,11 @@
"methods": [
"streaming_read_feature_values"
]
},
"WriteFeatureValues": {
"methods": [
"write_feature_values"
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,129 @@ async def sample_streaming_read_feature_values():
# Done; return the response.
return response

async def write_feature_values(
self,
request: Union[
featurestore_online_service.WriteFeatureValuesRequest, dict
] = None,
*,
entity_type: str = None,
payloads: Sequence[
featurestore_online_service.WriteFeatureValuesPayload
] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> featurestore_online_service.WriteFeatureValuesResponse:
r"""Writes Feature values of one or more entities of an
EntityType.
The Feature values are merged into existing entities if
any. The Feature values to be written must have
timestamp within the online storage retention.

.. code-block:: python

from google.cloud import aiplatform_v1beta1

async def sample_write_feature_values():
# Create a client
client = aiplatform_v1beta1.FeaturestoreOnlineServingServiceAsyncClient()

# Initialize request argument(s)
payloads = aiplatform_v1beta1.WriteFeatureValuesPayload()
payloads.entity_id = "entity_id_value"

request = aiplatform_v1beta1.WriteFeatureValuesRequest(
entity_type="entity_type_value",
payloads=payloads,
)

# Make the request
response = await client.write_feature_values(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.aiplatform_v1beta1.types.WriteFeatureValuesRequest, dict]):
The request object. Request message for
[FeaturestoreOnlineServingService.WriteFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreOnlineServingService.WriteFeatureValues].
entity_type (:class:`str`):
Required. The resource name of the EntityType for the
entities being written. Value format:
``projects/{project}/locations/{location}/featurestores/ {featurestore}/entityTypes/{entityType}``.
For example, for a machine learning model predicting
user clicks on a website, an EntityType ID could be
``user``.

This corresponds to the ``entity_type`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
payloads (:class:`Sequence[google.cloud.aiplatform_v1beta1.types.WriteFeatureValuesPayload]`):
Required. The entities to be written. Up to 100,000
feature values can be written across all ``payloads``.

This corresponds to the ``payloads`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.cloud.aiplatform_v1beta1.types.WriteFeatureValuesResponse:
Response message for
[FeaturestoreOnlineServingService.WriteFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreOnlineServingService.WriteFeatureValues].

"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([entity_type, payloads])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

request = featurestore_online_service.WriteFeatureValuesRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if entity_type is not None:
request.entity_type = entity_type
if payloads:
request.payloads.extend(payloads)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.write_feature_values,
default_timeout=None,
client_info=DEFAULT_CLIENT_INFO,
)

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

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def list_operations(
self,
request: operations_pb2.ListOperationsRequest = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,131 @@ def sample_streaming_read_feature_values():
# Done; return the response.
return response

def write_feature_values(
self,
request: Union[
featurestore_online_service.WriteFeatureValuesRequest, dict
] = None,
*,
entity_type: str = None,
payloads: Sequence[
featurestore_online_service.WriteFeatureValuesPayload
] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> featurestore_online_service.WriteFeatureValuesResponse:
r"""Writes Feature values of one or more entities of an
EntityType.
The Feature values are merged into existing entities if
any. The Feature values to be written must have
timestamp within the online storage retention.

.. code-block:: python

from google.cloud import aiplatform_v1beta1

def sample_write_feature_values():
# Create a client
client = aiplatform_v1beta1.FeaturestoreOnlineServingServiceClient()

# Initialize request argument(s)
payloads = aiplatform_v1beta1.WriteFeatureValuesPayload()
payloads.entity_id = "entity_id_value"

request = aiplatform_v1beta1.WriteFeatureValuesRequest(
entity_type="entity_type_value",
payloads=payloads,
)

# Make the request
response = client.write_feature_values(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.aiplatform_v1beta1.types.WriteFeatureValuesRequest, dict]):
The request object. Request message for
[FeaturestoreOnlineServingService.WriteFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreOnlineServingService.WriteFeatureValues].
entity_type (str):
Required. The resource name of the EntityType for the
entities being written. Value format:
``projects/{project}/locations/{location}/featurestores/ {featurestore}/entityTypes/{entityType}``.
For example, for a machine learning model predicting
user clicks on a website, an EntityType ID could be
``user``.

This corresponds to the ``entity_type`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
payloads (Sequence[google.cloud.aiplatform_v1beta1.types.WriteFeatureValuesPayload]):
Required. The entities to be written. Up to 100,000
feature values can be written across all ``payloads``.

This corresponds to the ``payloads`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.cloud.aiplatform_v1beta1.types.WriteFeatureValuesResponse:
Response message for
[FeaturestoreOnlineServingService.WriteFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreOnlineServingService.WriteFeatureValues].

"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([entity_type, payloads])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# Minor optimization to avoid making a copy if the user passes
# in a featurestore_online_service.WriteFeatureValuesRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(
request, featurestore_online_service.WriteFeatureValuesRequest
):
request = featurestore_online_service.WriteFeatureValuesRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if entity_type is not None:
request.entity_type = entity_type
if payloads is not None:
request.payloads = payloads

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

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

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

def __enter__(self):
return self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=5.0,
client_info=client_info,
),
self.write_feature_values: gapic_v1.method.wrap_method(
self.write_feature_values,
default_timeout=None,
client_info=client_info,
),
}

def close(self):
Expand Down Expand Up @@ -176,6 +181,18 @@ def streaming_read_feature_values(
]:
raise NotImplementedError()

@property
def write_feature_values(
self,
) -> Callable[
[featurestore_online_service.WriteFeatureValuesRequest],
Union[
featurestore_online_service.WriteFeatureValuesResponse,
Awaitable[featurestore_online_service.WriteFeatureValuesResponse],
],
]:
raise NotImplementedError()

@property
def list_operations(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,39 @@ def streaming_read_feature_values(
)
return self._stubs["streaming_read_feature_values"]

@property
def write_feature_values(
self,
) -> Callable[
[featurestore_online_service.WriteFeatureValuesRequest],
featurestore_online_service.WriteFeatureValuesResponse,
]:
r"""Return a callable for the write feature values method over gRPC.

Writes Feature values of one or more entities of an
EntityType.
The Feature values are merged into existing entities if
any. The Feature values to be written must have
timestamp within the online storage retention.

Returns:
Callable[[~.WriteFeatureValuesRequest],
~.WriteFeatureValuesResponse]:
A function that, when called, will call the underlying RPC
on the server.
"""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "write_feature_values" not in self._stubs:
self._stubs["write_feature_values"] = self.grpc_channel.unary_unary(
"/google.cloud.aiplatform.v1beta1.FeaturestoreOnlineServingService/WriteFeatureValues",
request_serializer=featurestore_online_service.WriteFeatureValuesRequest.serialize,
response_deserializer=featurestore_online_service.WriteFeatureValuesResponse.deserialize,
)
return self._stubs["write_feature_values"]

def close(self):
self.grpc_channel.close()

Expand Down
Loading