Skip to content

Commit 9b33dbd

Browse files
committed
fix: Remove deprecated run pipeline methods
1 parent b3be2e6 commit 9b33dbd

File tree

5 files changed

+34
-764
lines changed

5 files changed

+34
-764
lines changed

Diff for: README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ pip install --upgrade acd-sdk
2626

2727
## Migrating from version 1.x.x
2828

29-
The 2.0 release of the Annotator for Clinical Data SDK introduces a Python package name change from `ibm_whcs_sdk` to `acd_sdk`. For the migration from 1.x.x:
29+
The release of version 2 of the Annotator for Clinical Data SDK introduces a Python package name change from `ibm_whcs_sdk` to `acd_sdk`. For the migration from 1.x.x:
3030

31-
1. After running `pip install --upgrade acd-sdk`, confirm that you have version 2.0 installed by running `pip show acd-sdk`.
31+
1. Run `pip uninstall ibm-whcs-sdk`
32+
1. Run `pip install acd-sdk`, and confirm that you have version 2 installed by running `pip show acd-sdk`.
3233
2. In your application files that have a dependency on `acd-sdk`, update any import declarations from `ibm_whcs_sdk` to `acd_sdk`.
3334

3435
## Using the SDK

Diff for: acd_sdk/annotator_for_clinical_data/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from .annotator_for_clinical_data_v1 import AcdFlow
1212
from .annotator_for_clinical_data_v1 import AcdProfile
1313
from .annotator_for_clinical_data_v1 import AllergyMedication
14-
from .annotator_for_clinical_data_v1 import AnalyticFlowBeanInput
1514
from .annotator_for_clinical_data_v1 import Annotation
1615
from .annotator_for_clinical_data_v1 import Annotator
1716
from .annotator_for_clinical_data_v1 import AnnotatorFlow

Diff for: acd_sdk/annotator_for_clinical_data/annotator_for_clinical_data_v1.py

+3-275
Original file line numberDiff line numberDiff line change
@@ -660,124 +660,6 @@ def delete_flows(self, id: str, **kwargs) -> DetailedResponse:
660660
#########################
661661

662662

663-
# Method is deprecated and could be removed in the future. Use 'analyze' method instead.
664-
def run_pipeline(self, *, unstructured: List['UnstructuredContainer'] = None, annotator_flows: List['AnnotatorFlow'] = None, debug_text_restore: bool = None, return_analyzed_text: bool = None, **kwargs) -> DetailedResponse:
665-
"""
666-
Detect entities & relations from unstructured data.
667-
668-
<p>This API accepts a JSON request model featuring both the unstructured data to
669-
be analyzed as well as the desired annotator flow.<p/><p><b>Annotator
670-
Chaining</b><br/>Sample request invoking both the concept_detection and
671-
symptom_disease annotators asynchronously. This sample request references
672-
configurations via a profile id. Profiles define configurations that can be
673-
referenced within a request. Profile is optional. A default profile is used if no
674-
profile id is available in the annotator flow. The default profile contains the
675-
parameters for the concept detection and the attribute detection. An empty profile
676-
can be used if absolutely no parameters are attached to any annotators. See <a
677-
href=".." target="_blank">documentation</a> for more information. </p><pre>{<br/>
678-
"annotatorFlows": [<br/> {<br/> "profile" : "default_profile_v1.0", <br/>
679-
"flow": {<br/> "elements": [<br/> {<br/>
680-
"annotator": {<br/> "name": "concept_detection"<br/>
681-
}<br/> },<br/> {<br/> "annotator": {<br/>
682-
"name": "symptom_disease"<br/> }<br/> }<br/> ],<br/>
683-
"async": false<br/> }<br/> }<br/> ],<br/> "unstructured": [<br/>
684-
{<br/> "text": "Patient has lung cancer, but did not smoke. She may consider
685-
chemotherapy as part of a treatment plan."<br/> }<br/>
686-
]<br/>}<br/></pre><p><b>Annotation Filtering</b><br/>Sample request invoking
687-
concept_detection with a filter defined to exclude any annotations detected from
688-
concept_detection where the semanticType field does not equal
689-
"neop".</p><pre>{<br/> "annotatorFlows": [<br/> {<br/> "flow": {<br/>
690-
"elements": [<br/> {<br/> "annotator": {<br/>
691-
"name": "concept_detection",<br/> "configurations": [<br/>
692-
{<br/> "filter": {<br/> "target":
693-
"unstructured.data.concepts",<br/> "condition": {<br/>
694-
"type": "match",<br/> "field":
695-
"semanticType",<br/> "values": [<br/>
696-
"neop"<br/> ],<br/> "not":
697-
false,<br/> "caseInsensitive": false,<br/>
698-
"operator": "equals"<br/> }<br/> }<br/>
699-
}<br/> ]<br/> }<br/> }<br/>
700-
],<br/> "async": false<br/> }<br/> }<br/> ],<br/> "unstructured":
701-
[<br/> {<br/> "text": "Patient has lung cancer, but did not smoke. She may
702-
consider chemotherapy as part of a treatment plan."<br/> }<br/>
703-
]<br/>}<br/></pre><p><b>Annotators that support annotation filtering:</b> allergy,
704-
bathing_assistance, cancer, concept_detection, dressing_assistance,
705-
eating_assistance, ejection_fraction, lab_value, medication, named_entities,
706-
procedure, seeing_assistance, smoking, symptom_disease, toileting_assistance,
707-
walking_assistance.</p><hr/><p><b>Annotation Augmentation</b><br/>Sample request
708-
invoking the cancer annotator and providing a whitelist entry for a new custom
709-
surface form: "lungcancer".</p><pre>{<br/> "annotatorFlows": [<br/> {<br/>
710-
"flow": {<br/> "elements": [<br/> {<br/> "annotator":
711-
{<br/> "name": "cancer",<br/> "configurations": [<br/>
712-
{<br/> "whitelist": {<br/> "name":
713-
"cancer",<br/> "entries": [<br/> {<br/>
714-
"surfaceForms": [<br/> "lungcancer"<br/>
715-
],<br/> "features": {<br/> "normalizedName":
716-
"lung cancer",<br/> "hccCode": "9",<br/>
717-
"icd10Code": "C34.9",<br/> "ccsCode": "19",<br/>
718-
"icd9Code": "162.9",<br/> "conceptId": "93880001"<br/>
719-
}<br/> }<br/> ]<br/>
720-
}<br/> }<br/> ]<br/> }<br/>
721-
}<br/> ],<br/> "async": false<br/> }<br/> }<br/> ],<br/>
722-
"unstructured": [<br/> {<br/> "text": "The patient was diagnosed with
723-
lungcancer, on Dec 23, 2011."<br/> }<br/> ]<br/>}<br/></pre><b>Annotators that
724-
support annotation augmentation:</b> allergy, bathing_assistance, cancer,
725-
dressing_assistance, eating_assistance, ejection_fraction, lab_value, medication,
726-
named_entities, procedure, seeing_assistance, smoking, symptom_disease,
727-
toileting_assistance, walking_assistance.<br/>.
728-
729-
:param List[UnstructuredContainer] unstructured: (optional)
730-
:param List[AnnotatorFlow] annotator_flows: (optional)
731-
:param bool debug_text_restore: (optional) If true, any ReplaceTextChange
732-
annotations will be left in the container and the modified text before
733-
restoring to original form will stored in the metadata that is returned.
734-
Otherwise, these annotations and modified text will be removed from the
735-
container.
736-
:param bool return_analyzed_text: (optional) Set this to true to show the
737-
analyzed text in the response.
738-
:param dict headers: A `dict` containing the request headers
739-
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
740-
:rtype: DetailedResponse
741-
"""
742-
743-
warn("The 'run_pipeline' method is deprecated. Use 'analyze' method instead.", DeprecationWarning, stacklevel=2)
744-
745-
if unstructured is not None:
746-
unstructured = [ convert_model(x) for x in unstructured ]
747-
if annotator_flows is not None:
748-
annotator_flows = [ convert_model(x) for x in annotator_flows ]
749-
headers = {}
750-
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='run_pipeline')
751-
headers.update(sdk_headers)
752-
753-
params = {
754-
'version': self.version,
755-
'debug_text_restore': debug_text_restore,
756-
'return_analyzed_text': return_analyzed_text
757-
}
758-
759-
data = {
760-
'unstructured': unstructured,
761-
'annotatorFlows': annotator_flows
762-
}
763-
data = {k: v for (k, v) in data.items() if v is not None}
764-
data = json.dumps(data, cls=AnnotatorEncoder)
765-
headers['content-type'] = 'application/json'
766-
767-
if 'headers' in kwargs:
768-
headers.update(kwargs.get('headers'))
769-
770-
url = '/v1/analyze'
771-
request = self.prepare_request(method='POST',
772-
url=url,
773-
headers=headers,
774-
params=params,
775-
data=data)
776-
777-
response = self.request_acd(request)
778-
return response
779-
780-
781663
def analyze_org(self, unstructured=None, annotator_flows=None, **kwargs):
782664
"""
783665
Detect entities & relations from unstructured data and return as 'dict'.
@@ -893,89 +775,6 @@ def analyze(self, text, flow, **kwargs):
893775
return result
894776

895777

896-
# Method is deprecated and could be removed in the future. Use 'analyze_with_flow' instead.
897-
def run_pipeline_with_flow(self, flow_id: str, return_analyzed_text: bool, analytic_flow_bean_input: Union['AnalyticFlowBeanInput', str, TextIO], *, content_type: str = None, debug_text_restore: bool = None, **kwargs) -> DetailedResponse:
898-
"""
899-
analyze with a pre-specified flow.
900-
901-
<p>This API accepts a flow identifier as well as a <emph>TEXT</emph> or a
902-
<emph>JSON</emph> request model featuring the unstructured text to be analyzed.
903-
<p/><p><b>JSON request model with unstructured text </b></p><pre>{<br/>
904-
"unstructured": [<br/> {<br/> "text": "Patient has lung cancer, but did
905-
not smoke. She may consider chemotherapy as part of a treatment plan."<br/>
906-
}<br/> ]<br/>}<br/></pre><p><b>JSON request model with existing annotations
907-
</b><br/></p><pre>{<br> "unstructured": [<br> {<br> "text": "Patient will
908-
not start on cisplatin 80mg on 1/1/2018. Patient is also diabetic.",<br>
909-
"data": {<br> "concepts": [<br> {<br> "cui":
910-
"C0030705",<br> "preferredName": "Patients",<br>
911-
"semanticType": "podg",<br> "source": "umls",<br>
912-
"sourceVersion": "2017AA",<br> "type":
913-
"umls.PatientOrDisabledGroup",<br> "begin": 0,<br> "end":
914-
7,<br> "coveredText": "Patient"<br> }<br> ]<br> } <br>
915-
} <br> ]<br>}<br></pre>.
916-
917-
:param str flow_id: flow identifier .
918-
:param bool return_analyzed_text: Set this to true to show the analyzed
919-
text in the response.
920-
:param AnalyticFlowBeanInput analytic_flow_bean_input: Input request data
921-
in TEXT or JSON format .
922-
:param str content_type: (optional) The type of the input. A character
923-
encoding can be specified by including a `charset` parameter. For example,
924-
'text/plain;charset=utf-8'.
925-
:param bool debug_text_restore: (optional) If true, any ReplaceTextChange
926-
annotations will be left in the container and the modified text before
927-
restoring to original form will be returned in the metadata. Otherwise,
928-
these annotations and modified text will be removed from the container.
929-
:param dict headers: A `dict` containing the request headers
930-
:return: A `DetailedResponse` containing the result, headers and HTTP status code.
931-
:rtype: DetailedResponse
932-
"""
933-
934-
# Method is deprecated and could be removed in the future.
935-
warn("The 'run_pipeline_with_flow' method is deprecated. Use 'analyze_with_flow' method instead.", DeprecationWarning, stacklevel=2)
936-
937-
if flow_id is None:
938-
raise ValueError('flow_id must be provided')
939-
if return_analyzed_text is None:
940-
raise ValueError('return_analyzed_text must be provided')
941-
if analytic_flow_bean_input is None:
942-
raise ValueError('analytic_flow_bean_input must be provided')
943-
if isinstance(analytic_flow_bean_input, AnalyticFlowBeanInput):
944-
analytic_flow_bean_input = convert_model(analytic_flow_bean_input)
945-
content_type = content_type or 'application/json'
946-
headers = {
947-
'Content-Type': content_type
948-
}
949-
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='run_pipeline_with_flow')
950-
headers.update(sdk_headers)
951-
952-
params = {
953-
'version': self.version,
954-
'return_analyzed_text': return_analyzed_text,
955-
'debug_text_restore': debug_text_restore
956-
}
957-
958-
if isinstance(analytic_flow_bean_input, dict):
959-
data = json.dumps(analytic_flow_bean_input)
960-
if content_type is None:
961-
headers['content-type'] = 'application/json'
962-
else:
963-
data = analytic_flow_bean_input
964-
965-
if 'headers' in kwargs:
966-
headers.update(kwargs.get('headers'))
967-
968-
url = '/v1/analyze/{0}'.format(*self.encode_path_vars(flow_id))
969-
request = self.prepare_request(method='POST',
970-
url=url,
971-
headers=headers,
972-
params=params,
973-
data=data)
974-
975-
response = self.request_acd(request)
976-
return response
977-
978-
979778
def analyze_with_flow_org(self, flow_id, request, content_type='text/plain', **kwargs):
980779
"""
981780
Analyze with a persisted flow and return as a 'dict'.
@@ -1306,6 +1105,7 @@ def cartridges_get_id(self, id: str, **kwargs) -> DetailedResponse:
13061105
return response
13071106

13081107

1108+
# Method is deprecated and could be removed in the future. Use 'cartridges_post_multipart' method instead.
13091109
def deploy_cartridge(self, *, archive_file: BinaryIO = None, archive_file_content_type: str = None, update: bool = None, **kwargs) -> DetailedResponse:
13101110
"""
13111111
Deploy a cartridge.
@@ -1321,6 +1121,8 @@ def deploy_cartridge(self, *, archive_file: BinaryIO = None, archive_file_conten
13211121
:rtype: DetailedResponse with `dict` result representing a `DeployCartridgeResponse` object
13221122
"""
13231123

1124+
warn("The 'deploy_cartridge' method is deprecated. Use 'cartridges_post_multipart' method instead.", DeprecationWarning, stacklevel=2)
1125+
13241126
headers = {}
13251127
sdk_headers = get_sdk_headers(service_name=self.DEFAULT_SERVICE_NAME, service_version='V1', operation_id='deploy_cartridge')
13261128
headers.update(sdk_headers)
@@ -1391,20 +1193,6 @@ def get_health_check_status(self, *, accept: str = None, format: str = None, **k
13911193
return response
13921194

13931195

1394-
class RunPipelineWithFlowEnums:
1395-
"""
1396-
Enums for run_pipeline_with_flow parameters.
1397-
"""
1398-
1399-
class ContentType(Enum):
1400-
"""
1401-
The type of the input. A character encoding can be specified by including a
1402-
`charset` parameter. For example, 'text/plain;charset=utf-8'.
1403-
"""
1404-
APPLICATION_JSON = 'application/json'
1405-
TEXT_PLAIN = 'text/plain'
1406-
1407-
14081196
class GetServiceStatusEnums:
14091197
"""
14101198
Enums for get_service_status parameters.
@@ -2061,66 +1849,6 @@ def __str__(self):
20611849
"""Return a `str` version of this Annotation object."""
20621850
return json.dumps(self._to_dict(), indent=2)
20631851

2064-
class AnalyticFlowBeanInput():
2065-
"""
2066-
AnalyticFlowBeanInput.
2067-
2068-
:attr List[UnstructuredContainer] unstructured: (optional)
2069-
:attr List[AnnotatorFlow] annotator_flows: (optional)
2070-
"""
2071-
2072-
def __init__(self, *, unstructured: List['UnstructuredContainer'] = None, annotator_flows: List['AnnotatorFlow'] = None) -> None:
2073-
"""
2074-
Initialize a AnalyticFlowBeanInput object.
2075-
2076-
:param List[UnstructuredContainer] unstructured: (optional)
2077-
:param List[AnnotatorFlow] annotator_flows: (optional)
2078-
"""
2079-
self.unstructured = unstructured
2080-
self.annotator_flows = annotator_flows
2081-
2082-
@classmethod
2083-
def from_dict(cls, _dict: Dict) -> 'AnalyticFlowBeanInput':
2084-
"""Initialize a AnalyticFlowBeanInput object from a json dictionary."""
2085-
args = {}
2086-
if 'unstructured' in _dict:
2087-
args['unstructured'] = [UnstructuredContainer.from_dict(x) for x in _dict.get('unstructured')]
2088-
if 'annotatorFlows' in _dict:
2089-
args['annotator_flows'] = [AnnotatorFlow.from_dict(x) for x in _dict.get('annotatorFlows')]
2090-
return cls(**args)
2091-
2092-
@classmethod
2093-
def _from_dict(cls, _dict):
2094-
"""Initialize a AnalyticFlowBeanInput object from a json dictionary."""
2095-
return cls.from_dict(_dict)
2096-
2097-
def to_dict(self) -> Dict:
2098-
"""Return a json dictionary representing this model."""
2099-
_dict = {}
2100-
if hasattr(self, 'unstructured') and self.unstructured is not None:
2101-
_dict['unstructured'] = [x.to_dict() for x in self.unstructured]
2102-
if hasattr(self, 'annotator_flows') and self.annotator_flows is not None:
2103-
_dict['annotatorFlows'] = [x.to_dict() for x in self.annotator_flows]
2104-
return _dict
2105-
2106-
def _to_dict(self):
2107-
"""Return a json dictionary representing this model."""
2108-
return self.to_dict()
2109-
2110-
def __str__(self) -> str:
2111-
"""Return a `str` version of this AnalyticFlowBeanInput object."""
2112-
return json.dumps(self.to_dict(), indent=2)
2113-
2114-
def __eq__(self, other: 'AnalyticFlowBeanInput') -> bool:
2115-
"""Return `true` when self and other are equal, false otherwise."""
2116-
if not isinstance(other, self.__class__):
2117-
return False
2118-
return self.__dict__ == other.__dict__
2119-
2120-
def __ne__(self, other: 'AnalyticFlowBeanInput') -> bool:
2121-
"""Return `true` when self and other are not equal, false otherwise."""
2122-
return not self == other
2123-
21241852

21251853
class Annotator():
21261854
"""

0 commit comments

Comments
 (0)