Skip to content

Commit

Permalink
adding limits to retention period
Browse files Browse the repository at this point in the history
  • Loading branch information
akamor committed Dec 3, 2024
1 parent 057233c commit cdf04cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/source/redact/redacting_text.rst
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,4 @@ When you use the :meth:`redact<tonic_textual.redact_api.TextualNer.redact>` meth
tags=["my_first_request"])
)
The above code runs the redaction in the same way as any other redaction request, and then records the API request and its results. The request itself is automatically purged after 1 hour. You can view the results from the **API Explorer** page in Textual.
The above code runs the redaction in the same way as any other redaction request, and then records the API request and its results. The request itself is automatically purged after 1 hour. You can view the results from the **API Explorer** page in Textual. The retention time is specified in hours and can be set to a value between 1 and 720.
6 changes: 5 additions & 1 deletion tonic_textual/redact_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from tonic_textual.classes.dataset import Dataset
from tonic_textual.classes.datasetfile import DatasetFile
from tonic_textual.classes.tonic_exception import (
BadArgumentsException,
DatasetNameAlreadyExists,
InvalidJsonForRedactionRequest,
FileNotReadyForDownload,
Expand Down Expand Up @@ -257,7 +258,7 @@ def redact(
the text is marked as the entity type and is included in the redaction or synthesis.
record_options: RecordApiRequestOptions
A value to record the API request and results for analysis in the Textual application. The default value is to not record the API request and results in the Textual application.
A value to record the API request and results for analysis in the Textual application. The default value is to not record the API request.
Returns
-------
Expand Down Expand Up @@ -299,6 +300,9 @@ def redact(
}

if record_options.record:
if record_options.retention_time_in_hours <= 0 or record_options.retention_time_in_hours>720:
raise BadArgumentsException("The retention time must be set between 1 and 720 hours")

record_payload = { "retentionTimeInHours": record_options.retention_time_in_hours, "tags": record_options.tags, "record": True}
payload["recordApiRequestOptions"] = record_payload
else:
Expand Down

0 comments on commit cdf04cd

Please sign in to comment.