Skip to content

feat: add deleteFeatureValues in aiplatform v1beta1 featurestore_service.proto #1670

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

Merged
merged 4 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 9 additions & 9 deletions google/cloud/aiplatform_v1/services/migration_service/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,40 +218,40 @@ def parse_dataset_path(path: str) -> Dict[str, str]:
@staticmethod
def dataset_path(
project: str,
location: str,
dataset: str,
) -> str:
"""Returns a fully-qualified dataset string."""
return "projects/{project}/datasets/{dataset}".format(
return "projects/{project}/locations/{location}/datasets/{dataset}".format(
project=project,
location=location,
dataset=dataset,
)

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

@staticmethod
def dataset_path(
project: str,
location: str,
dataset: str,
) -> str:
"""Returns a fully-qualified dataset string."""
return "projects/{project}/locations/{location}/datasets/{dataset}".format(
return "projects/{project}/datasets/{dataset}".format(
project=project,
location=location,
dataset=dataset,
)

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

@staticmethod
Expand Down
8 changes: 8 additions & 0 deletions google/cloud/aiplatform_v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@
from .types.featurestore_service import DeleteEntityTypeRequest
from .types.featurestore_service import DeleteFeatureRequest
from .types.featurestore_service import DeleteFeaturestoreRequest
from .types.featurestore_service import DeleteFeatureValuesOperationMetadata
from .types.featurestore_service import DeleteFeatureValuesRequest
from .types.featurestore_service import DeleteFeatureValuesResponse
from .types.featurestore_service import DestinationFeatureSetting
from .types.featurestore_service import EntityIdSelector
from .types.featurestore_service import ExportFeatureValuesOperationMetadata
from .types.featurestore_service import ExportFeatureValuesRequest
from .types.featurestore_service import ExportFeatureValuesResponse
Expand Down Expand Up @@ -663,6 +667,9 @@
"DeleteEntityTypeRequest",
"DeleteExecutionRequest",
"DeleteFeatureRequest",
"DeleteFeatureValuesOperationMetadata",
"DeleteFeatureValuesRequest",
"DeleteFeatureValuesResponse",
"DeleteFeaturestoreRequest",
"DeleteHyperparameterTuningJobRequest",
"DeleteIndexEndpointRequest",
Expand Down Expand Up @@ -701,6 +708,7 @@
"EncryptionSpec",
"Endpoint",
"EndpointServiceClient",
"EntityIdSelector",
"EntityType",
"EnvVar",
"Event",
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 @@ -361,6 +361,11 @@
"delete_feature"
]
},
"DeleteFeatureValues": {
"methods": [
"delete_feature_values"
]
},
"DeleteFeaturestore": {
"methods": [
"delete_featurestore"
Expand Down Expand Up @@ -466,6 +471,11 @@
"delete_feature"
]
},
"DeleteFeatureValues": {
"methods": [
"delete_feature_values"
]
},
"DeleteFeaturestore": {
"methods": [
"delete_featurestore"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,140 @@ async def sample_export_feature_values():
# Done; return the response.
return response

async def delete_feature_values(
self,
request: Union[featurestore_service.DeleteFeatureValuesRequest, dict] = None,
*,
entity_type: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Delete Feature values from Featurestore.
The progress of the deletion is tracked by the returned
operation. The deleted feature values are guaranteed to
be invisible to subsequent read operations after the
operation is marked as successfully done.
If a delete feature values operation fails, the feature
values returned from reads and exports may be
inconsistent. If consistency is required, the caller
must retry the same delete request again and wait till
the new operation returned is marked as successfully
done.

.. code-block:: python

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import aiplatform_v1beta1

async def sample_delete_feature_values():
# Create a client
client = aiplatform_v1beta1.FeaturestoreServiceAsyncClient()

# Initialize request argument(s)
select_entity = aiplatform_v1beta1.SelectEntity()
select_entity.entity_id_selector.csv_source.gcs_source.uris = ['uris_value1', 'uris_value2']

request = aiplatform_v1beta1.DeleteFeatureValuesRequest(
select_entity=select_entity,
entity_type="entity_type_value",
)

# Make the request
operation = client.delete_feature_values(request=request)

print("Waiting for operation to complete...")

response = await operation.result()

# Handle the response
print(response)

Args:
request (Union[google.cloud.aiplatform_v1beta1.types.DeleteFeatureValuesRequest, dict]):
The request object. Request message for
[FeaturestoreService.DeleteFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreService.DeleteFeatureValues].
entity_type (:class:`str`):
Required. The resource name of the EntityType grouping
the Features for which values are being deleted from.
Format:
``projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entityType}``

This corresponds to the ``entity_type`` 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.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.

The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.DeleteFeatureValuesResponse` Response message for
[FeaturestoreService.DeleteFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreService.DeleteFeatureValues].

"""
# 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])
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_service.DeleteFeatureValuesRequest(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

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.delete_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,
)

# Wrap the response in an operation future.
response = operation_async.from_gapic(
response,
self._client._transport.operations_client,
featurestore_service.DeleteFeatureValuesResponse,
metadata_type=featurestore_service.DeleteFeatureValuesOperationMetadata,
)

# Done; return the response.
return response

async def search_features(
self,
request: Union[featurestore_service.SearchFeaturesRequest, dict] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2978,6 +2978,140 @@ def sample_export_feature_values():
# Done; return the response.
return response

def delete_feature_values(
self,
request: Union[featurestore_service.DeleteFeatureValuesRequest, dict] = None,
*,
entity_type: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> gac_operation.Operation:
r"""Delete Feature values from Featurestore.
The progress of the deletion is tracked by the returned
operation. The deleted feature values are guaranteed to
be invisible to subsequent read operations after the
operation is marked as successfully done.
If a delete feature values operation fails, the feature
values returned from reads and exports may be
inconsistent. If consistency is required, the caller
must retry the same delete request again and wait till
the new operation returned is marked as successfully
done.

.. code-block:: python

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import aiplatform_v1beta1

def sample_delete_feature_values():
# Create a client
client = aiplatform_v1beta1.FeaturestoreServiceClient()

# Initialize request argument(s)
select_entity = aiplatform_v1beta1.SelectEntity()
select_entity.entity_id_selector.csv_source.gcs_source.uris = ['uris_value1', 'uris_value2']

request = aiplatform_v1beta1.DeleteFeatureValuesRequest(
select_entity=select_entity,
entity_type="entity_type_value",
)

# Make the request
operation = client.delete_feature_values(request=request)

print("Waiting for operation to complete...")

response = operation.result()

# Handle the response
print(response)

Args:
request (Union[google.cloud.aiplatform_v1beta1.types.DeleteFeatureValuesRequest, dict]):
The request object. Request message for
[FeaturestoreService.DeleteFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreService.DeleteFeatureValues].
entity_type (str):
Required. The resource name of the EntityType grouping
the Features for which values are being deleted from.
Format:
``projects/{project}/locations/{location}/featurestores/{featurestore}/entityTypes/{entityType}``

This corresponds to the ``entity_type`` 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.api_core.operation.Operation:
An object representing a long-running operation.

The result type for the operation will be :class:`google.cloud.aiplatform_v1beta1.types.DeleteFeatureValuesResponse` Response message for
[FeaturestoreService.DeleteFeatureValues][google.cloud.aiplatform.v1beta1.FeaturestoreService.DeleteFeatureValues].

"""
# 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])
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_service.DeleteFeatureValuesRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, featurestore_service.DeleteFeatureValuesRequest):
request = featurestore_service.DeleteFeatureValuesRequest(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

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.delete_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,
)

# Wrap the response in an operation future.
response = gac_operation.from_gapic(
response,
self._transport.operations_client,
featurestore_service.DeleteFeatureValuesResponse,
metadata_type=featurestore_service.DeleteFeatureValuesOperationMetadata,
)

# Done; return the response.
return response

def search_features(
self,
request: Union[featurestore_service.SearchFeaturesRequest, dict] = None,
Expand Down
Loading