Writes a batch of Records to one or more FeatureGroups. Use this API for bulk ingestion of records into the OnlineStore and OfflineStore.
You can set the ingested records to expire at a given time to live (TTL) duration after the record's event time by specifying the TtlDuration parameter. A request level TtlDuration applies to all entries that do not specify their own TtlDuration.
Parameters:
-
entries
(Optional[BatchWriteRecordEntries], default:
None
)
–
A list of records to write. Each entry specifies the FeatureGroup, the record data, and optionally target stores and a TTL duration.
-
ttl_duration
(Optional[TtlDuration], default:
None
)
–
Time to live duration applied to all entries in the batch that do not specify their own TtlDuration; ExpiresAt = EventTime + TtlDuration. For information on HardDelete, see the DeleteRecord API in the Amazon SageMaker API Reference guide.
Raises:
-
AccessForbidden
–
You do not have permission to perform an action.
-
InternalFailure
–
An internal failure occurred. Try your request again. If the problem persists, contact Amazon Web Services customer support.
-
ResourceNotFound
–
A resource that is required to perform an action was not found.
-
ServiceUnavailable
–
The service is currently unavailable.
-
ValidationError
–
There was an error validating your request.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Examples:
Write records to multiple feature groups
>>> client.batch_write_record(entries=[{'FeatureGroupName': 'my-feature-group', 'Record': [{'FeatureName': 'customer_id', 'ValueAsString': 'cust-001'}, {'FeatureName': 'age', 'ValueAsString': '25'}]}])
Source code in docs_src/capo_sagemaker_featurestore_runtime/_services/sage_maker_feature_store_runtime.py
| def batch_write_record(
self,
*,
config_overrides: Optional[SageMakerFeatureStoreRuntimeClientConfig] = None,
entries: Optional[
"capo_sagemaker_featurestore_runtime.types.batch_write_record_entries.BatchWriteRecordEntries"
] = None,
ttl_duration: Optional[
"capo_sagemaker_featurestore_runtime.types.ttl_duration.TtlDuration"
] = None,
) -> "capo_sagemaker_featurestore_runtime.types.batch_write_record_response.BatchWriteRecordResponse":
"""<p>Writes a batch of <code>Records</code> to one or more <code>FeatureGroup</code>s. Use this API for bulk ingestion of records into the <code>OnlineStore</code> and <code>OfflineStore</code>.</p> <p>You can set the ingested records to expire at a given time to live (TTL) duration after the record's event time by specifying the <code>TtlDuration</code> parameter. A request level <code>TtlDuration</code> applies to all entries that do not specify their own <code>TtlDuration</code>.</p>
Args:
entries: <p>A list of records to write. Each entry specifies the <code>FeatureGroup</code>, the record data, and optionally target stores and a TTL duration.</p>
ttl_duration: <p>Time to live duration applied to all entries in the batch that do not specify their own <code>TtlDuration</code>; <code>ExpiresAt</code> = <code>EventTime</code> + <code>TtlDuration</code>. For information on HardDelete, see the <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_feature_store_DeleteRecord.html">DeleteRecord</a> API in the Amazon SageMaker API Reference guide.</p>
Raises:
capo_sagemaker_featurestore_runtime.errors.access_forbidden.AccessForbidden: <p>You do not have permission to perform an action.</p>
capo_sagemaker_featurestore_runtime.errors.internal_failure.InternalFailure: <p>An internal failure occurred. Try your request again. If the problem persists, contact Amazon Web Services customer support.</p>
capo_sagemaker_featurestore_runtime.errors.resource_not_found.ResourceNotFound: <p>A resource that is required to perform an action was not found.</p>
capo_sagemaker_featurestore_runtime.errors.service_unavailable.ServiceUnavailable: <p>The service is currently unavailable.</p>
capo_sagemaker_featurestore_runtime.errors.validation_error.ValidationError: <p>There was an error validating your request.</p>
capo_sagemaker_featurestore_runtime.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
Write records to multiple feature groups
>>> client.batch_write_record(entries=[{'FeatureGroupName': 'my-feature-group', 'Record': [{'FeatureName': 'customer_id', 'ValueAsString': 'cust-001'}, {'FeatureName': 'age', 'ValueAsString': '25'}]}])
"""
def _handler(
req: "OperationRequest[capo_sagemaker_featurestore_runtime.types.batch_write_record_request.BatchWriteRecordRequest]",
) -> OperationResponse[
"capo_sagemaker_featurestore_runtime.types.batch_write_record_response.BatchWriteRecordResponse"
]:
import capo_sagemaker_featurestore_runtime._operations.amazon_sage_maker_feature_store_runtime.batch_write_record
output, http_response = (
capo_sagemaker_featurestore_runtime._operations.amazon_sage_maker_feature_store_runtime.batch_write_record.batch_write_record(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("BatchWriteRecord")
)
input_: capo_sagemaker_featurestore_runtime.types.batch_write_record_request.BatchWriteRecordRequest = {}
if entries is not None:
input_["entries"] = entries
if ttl_duration is not None:
input_["ttl_duration"] = ttl_duration
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|