@@ -127,13 +127,13 @@ async def wait_for_task_output(self, timeout: Union[float, None] = 60 * 10) -> T
127127
128128
129129class TaskFailedError (Exception ):
130- def __init__ (self , task_details : Union [ TaskRetrieveResponse , WorkflowInvocationRetrieveResponse ] ):
130+ def __init__ (self , task_details : TaskRetrieveResponse ):
131131 self .task_details = task_details
132132 super ().__init__ (f"Task failed" )
133133
134134
135135class TaskTimeoutError (Exception ):
136- def __init__ (self , task_details : Union [ TaskRetrieveResponse , WorkflowInvocationRetrieveResponse ] ):
136+ def __init__ (self , task_details : TaskRetrieveResponse ):
137137 self .task_details = task_details
138138 super ().__init__ (f"Task timed out" )
139139
@@ -265,12 +265,14 @@ def wait_for_task_output(self, timeout: Union[float, None] = 60 * 10) -> Workflo
265265 """
266266 When called, this will block until the workflow invocation is complete.
267267
268- If the invocation fails or is cancelled, a `TaskFailedError` will be raised.
268+ If the invocation fails or is cancelled, a `WorkflowInvocationFailedError`
269+ will be raised.
269270
270271 Args:
271272 timeout: The maximum amount of time to wait in seconds. If not specified,
272- the default timeout is 10 minutes. Will raise a `TaskTimeoutError` if
273- the invocation does not complete within the timeout.
273+ the default timeout is 10 minutes. Will raise a
274+ `WorkflowInvocationTimeoutError` if the invocation does not complete
275+ within the timeout.
274276
275277 Returns:
276278 The workflow invocation details, equivalent to calling
@@ -284,13 +286,15 @@ async def wait_for_task_output(self, timeout: Union[float, None] = 60 * 10) -> W
284286 """
285287 When called, this will wait until the workflow invocation is complete.
286288
287- If the invocation fails or is cancelled, a `TaskFailedError` will be raised.
289+ If the invocation fails or is cancelled, a `WorkflowInvocationFailedError`
290+ will be raised.
288291
289292 Args:
290293 timeout: The maximum amount of time to wait in seconds. If not specified,
291- the default timeout is 10 minutes. Will raise a `TaskTimeoutError` if
292- the invocation does not complete within the timeout. Setting this to
293- `None` will wait indefinitely (disabling the timeout).
294+ the default timeout is 10 minutes. Will raise a
295+ `WorkflowInvocationTimeoutError` if the invocation does not complete
296+ within the timeout. Setting this to `None` will wait indefinitely
297+ (disabling the timeout).
294298
295299 Returns:
296300 The workflow invocation details, equivalent to awaiting
@@ -361,6 +365,18 @@ class AsyncAwaitableWISucceeded(AsyncAwaitableWorkflowInvocationResponseMixin, W
361365]
362366
363367
368+ class WorkflowInvocationFailedError (Exception ):
369+ def __init__ (self , invocation_details : WorkflowInvocationRetrieveResponse ):
370+ self .invocation_details = invocation_details
371+ super ().__init__ ("Workflow invocation failed" )
372+
373+
374+ class WorkflowInvocationTimeoutError (Exception ):
375+ def __init__ (self , invocation_details : WorkflowInvocationRetrieveResponse ):
376+ self .invocation_details = invocation_details
377+ super ().__init__ ("Workflow invocation timed out" )
378+
379+
364380def _make_sync_wait_for_workflow_invocation_output (
365381 client : "RunwayML" ,
366382) -> Callable [["AwaitableWorkflowInvocationResponseMixin" , Union [float , None ]], WorkflowInvocationRetrieveResponse ]:
@@ -374,9 +390,9 @@ def wait_for_task_output(
374390 if details .status == "SUCCEEDED" :
375391 return details
376392 if details .status == "FAILED" or details .status == "CANCELLED" :
377- raise TaskFailedError (details )
393+ raise WorkflowInvocationFailedError (details )
378394 if timeout is not None and time .time () - start_time > timeout :
379- raise TaskTimeoutError (details )
395+ raise WorkflowInvocationTimeoutError (details )
380396
381397 return wait_for_task_output
382398
@@ -406,9 +422,9 @@ async def wait_for_task_output(
406422 if details .status == "SUCCEEDED" :
407423 return details
408424 if details .status == "FAILED" or details .status == "CANCELLED" :
409- raise TaskFailedError (details )
425+ raise WorkflowInvocationFailedError (details )
410426 if timeout is not None and anyio .current_time () - start_time > timeout :
411- raise TaskTimeoutError (details )
427+ raise WorkflowInvocationTimeoutError (details )
412428
413429 return wait_for_task_output
414430
0 commit comments