Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Joe Ferrara <[email protected]>
  • Loading branch information
akamor and joeferraratonic authored Dec 3, 2024
1 parent a1743d6 commit 057233c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
6 changes: 3 additions & 3 deletions tonic_textual/classes/record_api_request_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class RecordApiRequestOptions(dict):
retention_time_in_hours: int
The number of hours to store the request. The request is then purged automatically.
tags : Optional[List[str]]
An optional list of tags to assign to the request. Used to help search for the request on the API Explorer page.
tags : List[str]
A list of tags to assign to the request. Used to help search for the request on the API Explorer page. The default is the empty list [], which corresponds to assigning no tags to the request.
"""
def __init__(self, record: bool, retention_time_in_hours: int, tags: Optional[List[str]] = []):
def __init__(self, record: bool, retention_time_in_hours: int, tags: List[str] = []):
self.record = record
self.retention_time_in_hours = retention_time_in_hours
self.tags = tags
Expand Down
12 changes: 4 additions & 8 deletions tonic_textual/redact_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def redact(
random_seed: Optional[int] = None,
label_block_lists: Optional[Dict[str, List[str]]] = None,
label_allow_lists: Optional[Dict[str, List[str]]] = None,
record_options: Optional[RecordApiRequestOptions] = default_record_options
record_options: RecordApiRequestOptions = default_record_options
) -> RedactionResponse:
"""Redacts a string. Depending on the configured handling for each sensitive
data type, values are either redacted, synthesized, or ignored.
Expand Down Expand Up @@ -256,8 +256,8 @@ def redact(
A dictionary of (entity type, additional values). When a piece of text matches a listed regular expression,
the text is marked as the entity type and is included in the redaction or synthesis.
record_options: Optional[RecordApiRequestOptions]
An optional value to record API the request and results for analysis in the Textual application. The default value is False.
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.
Returns
-------
Expand Down Expand Up @@ -313,8 +313,7 @@ def redact_bulk(
generator_default: PiiState = PiiState.Redaction,
random_seed: Optional[int] = None,
label_block_lists: Optional[Dict[str, List[str]]] = None,
label_allow_lists: Optional[Dict[str, List[str]]] = None,
record: Optional[RecordApiRequestOptions] = False
label_allow_lists: Optional[Dict[str, List[str]]] = None
) -> BulkRedactionResponse:
"""Redacts a string. Depending on the configured handling for each sensitive
data type, values are either redacted, synthesized, or ignored.
Expand Down Expand Up @@ -346,8 +345,6 @@ def redact_bulk(
A dictionary of (entity type, additional values). When a piece of text matches a listed regular expression,
the text is marked as the entity type and is included in the redaction or synthesis.
record: Optional[bool]
An optional value to record the API request and results for analysis in the Textual application. The default value is False.
Returns
-------
Expand Down Expand Up @@ -388,7 +385,6 @@ def redact_bulk(
for k, v in label_allow_lists.items()
}

payload["record"] = True if record else False

return self.send_redact_bulk_request("/api/redact/bulk", payload, random_seed)

Expand Down

0 comments on commit 057233c

Please sign in to comment.