2323from enum import Enum
2424from typing import BinaryIO , Dict , List , TextIO , Union
2525import json
26+ from warnings import warn
2627
2728from ibm_cloud_sdk_core import BaseService , DetailedResponse , ApiException
2829from ibm_cloud_sdk_core .authenticators .authenticator import Authenticator
@@ -665,6 +666,7 @@ def delete_flows(self, id: str, **kwargs) -> DetailedResponse:
665666 #########################
666667
667668
669+ # Method is deprecated and could be removed in the future. Use 'analyze' method instead.
668670 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 :
669671 """
670672 Detect entities & relations from unstructured data.
@@ -744,6 +746,8 @@ def run_pipeline(self, *, unstructured: List['UnstructuredContainer'] = None, an
744746 :rtype: DetailedResponse
745747 """
746748
749+ warn ("The 'run_pipeline' method is deprecated. Use 'analyze' method instead." , DeprecationWarning , stacklevel = 2 )
750+
747751 if unstructured is not None :
748752 unstructured = [ convert_model (x ) for x in unstructured ]
749753 if annotator_flows is not None :
@@ -763,7 +767,7 @@ def run_pipeline(self, *, unstructured: List['UnstructuredContainer'] = None, an
763767 'annotatorFlows' : annotator_flows
764768 }
765769 data = {k : v for (k , v ) in data .items () if v is not None }
766- data = json .dumps (data )
770+ data = json .dumps (data , cls = AnnotatorEncoder )
767771 headers ['content-type' ] = 'application/json'
768772
769773 if 'headers' in kwargs :
@@ -895,6 +899,7 @@ def analyze(self, text, flow, **kwargs):
895899 return result
896900
897901
902+ # Method is deprecated and could be removed in the future. Use 'analyze_with_flow' instead.
898903 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 :
899904 """
900905 analyze with a pre-specified flow.
@@ -932,6 +937,9 @@ def run_pipeline_with_flow(self, flow_id: str, return_analyzed_text: bool, analy
932937 :rtype: DetailedResponse
933938 """
934939
940+ # Method is deprecated and could be removed in the future.
941+ warn ("The 'run_pipeline_with_flow' method is deprecated. Use 'analyze_with_flow' method instead." , DeprecationWarning , stacklevel = 2 )
942+
935943 if flow_id is None :
936944 raise ValueError ('flow_id must be provided' )
937945 if return_analyzed_text is None :
0 commit comments