in src/clients/comprehend_client.py [0:0]
def contains_pii_entities(self, documents: List[Document], language=DEFAULT_LANGUAGE_CODE) -> List[Document]:
"""Call comprehend to get pii classification of given documents."""
documents_copy = deepcopy(documents)
result = []
with self.classification_executor_service:
futures = []
for doc in documents_copy:
futures.append(self.classification_executor_service.submit(self._update_doc_with_pii_classification, doc, language))
for future_result in as_completed(futures):
try:
result.append(future_result.result())
except Exception as error:
LOG.error("Error occurred while calling comprehend for classifying text as pii", exc_info=True)
self.classify_metrics.add_fault_count()
raise error
return result