@@ -76,9 +76,19 @@ def __init__(self, client):
7676 stop = stop_after_attempt (5 ),
7777 reraise = True
7878 )
79- def make_request (self , method , endpoint , ** kwargs ):
79+ def make_request (self , method : str , endpoint : str , ** kwargs ):
8080 url = f"{ self .api_base } { endpoint } "
81- response = requests .request (method , url , headers = self .headers , auth = self .auth , timeout = 5 , ** kwargs )
81+ response = requests .request (method , url , headers = self .headers , auth = self .auth , timeout = 30 , ** kwargs )
82+ response .raise_for_status ()
83+
84+ try :
85+ return response .json ().get ("collection" , {}).get ("items" , [])
86+ except ValueError :
87+ return response .text
88+
89+ def post_request (self , endpoint : str , ** kwargs ):
90+ url = f"{ self .api_base } { endpoint } "
91+ response = requests .request ("POST" , url , headers = self .headers , auth = self .auth , timeout = 30 , ** kwargs )
8292 response .raise_for_status ()
8393
8494 try :
@@ -93,6 +103,7 @@ def get_pipeline_id(self, name: str) -> int:
93103 """Fetch pipeline ID by name."""
94104 logger .info (f"Fetching ID for pipeline: { name } " )
95105 response = self .make_request ("GET" , f"/pipelines/search/?name={ name } " )
106+
96107 for item in response :
97108 for field in item .get ("data" , []):
98109 if field .get ("name" ) == "id" :
@@ -113,7 +124,7 @@ def post_workflow(self, pipeline_id: int, previous_id: int, params: list[dict])
113124 "previous_plugin_inst_id" : previous_id ,
114125 "nodes_info" : json .dumps (params )
115126 }
116- return self .make_request ( "POST" , f"/pipelines/{ pipeline_id } /workflows/" , json = payload )
127+ return self .post_request ( f"/pipelines/{ pipeline_id } /workflows/" , json = payload )
117128
118129 def run_pipeline (self , pipeline_name : str , previous_inst : int , pipeline_params : dict ):
119130 """
@@ -129,7 +140,7 @@ def run_pipeline(self, pipeline_name: str, previous_inst: int, pipeline_params:
129140 nodes_info = compute_workflow_nodes_info (default_params , include_all_defaults = True )
130141 updated_params = update_plugin_parameters (nodes_info , pipeline_params )
131142 workflow = self .post_workflow (pipeline_id = pipeline_id , previous_id = previous_inst , params = updated_params )
132- logger .info (f"Workflow posted successfully: { workflow } " )
143+ logger .info (f"Workflow posted successfully" )
133144 return {"status" : "Pipeline running" }
134145 except Exception as ex :
135146 logger .error (f"Running pipeline failed due to: { ex } " )
0 commit comments