Skip to content

Commit 1280572

Browse files
authored
Merge pull request #116 from microsoft/omri/make_azure_sdk_optional
2 parents 0a2b787 + b2a202f commit 1280572

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

presidio_evaluator/models/text_analytics_wrapper.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
import warnings
12
from typing import List, Optional, Dict
23

34
from presidio_evaluator import InputSample, span_to_tag
45
from presidio_evaluator.models import BaseModel
5-
from azure.ai.textanalytics import TextAnalyticsClient
6-
from azure.core.credentials import AzureKeyCredential
6+
7+
try:
8+
from azure.ai.textanalytics import TextAnalyticsClient
9+
from azure.core.credentials import AzureKeyCredential
10+
except ImportError:
11+
TextAnalyticsClient = None
12+
AzureKeyCredential = None
713

814

915
class TextAnalyticsWrapper(BaseModel):
@@ -31,11 +37,22 @@ def __init__(
3137
labeling_scheme=labeling_scheme,
3238
entity_mapping=entity_mapping,
3339
)
40+
41+
warnings.warn(
42+
f"{self.__class__.__name__} is deprecated and will be removed in a future version."
43+
f"Please use the TextAnalyticsRecognizer within Presidio Analyzer instead.",
44+
DeprecationWarning,
45+
stacklevel=2,
46+
)
47+
3448
self.score_threshold = score_threshold
3549
self.language = language
3650
self.ta_key = ta_key
3751
self.ta_endpoint = ta_endpoint
3852

53+
if not TextAnalyticsClient:
54+
raise ImportError("azure.ai.textanalytics is not installed")
55+
3956
if not ta_client:
4057
ta_client = self.__authenticate_client(ta_key, ta_endpoint)
4158
self.ta_client = ta_client

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "presidio_evaluator"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
description = ""
55
authors = ["Microsoft"]
66
readme = "README.md"
@@ -21,7 +21,6 @@ requests = "^2.25"
2121
xmltodict = "^0.12.0"
2222
python-dotenv = "^1.0.0"
2323
plotly= "^5.24.0"
24-
azure-ai-textanalytics = "^5.3.0"
2524

2625
# optional dependencies for the different NLP approaches
2726
[tool.poetry.group.ner]
@@ -31,6 +30,7 @@ optional=true
3130
flair = "^0.14.0"
3231
spacy_stanza = "^1.0.0"
3332
spacy_huggingface_pipelines = "^0.0.4"
33+
azure-ai-textanalytics = "^5.3.0"
3434

3535

3636
[tool.poetry.group.dev.dependencies]

0 commit comments

Comments
 (0)