Lee-W commented on code in PR #72149:
URL: https://github.com/apache/airflow/pull/72149#discussion_r4130181261


##########
providers/openai/src/airflow/providers/openai/operators/openai.py:
##########
@@ -361,8 +365,16 @@ class OpenAITriggerBatchOperator(BaseOperator):
     :param wait_seconds: Optional. Number of seconds between checks. Only used 
when ``deferrable`` is False.
         Defaults to 3 seconds.
     :param timeout: Optional. The amount of time, in seconds, to wait for the 
request to complete.
-        Applies in both deferrable and non-deferrable mode. Defaults to 24 
hours, which is the SLA for
-        OpenAI Batch API.
+        Applies in both deferrable and non-deferrable mode: in the synchronous 
path it bounds
+        ``wait_for_batch``; in the deferrable path it bounds the trigger's 
poll loop. When the
+        deferrable path times out, the operator requests cancellation of the 
batch using the
+        batch id carried by the trigger event, mirroring the synchronous path. 
Cancellation on
+        OpenAI's side is asynchronous — the batch reports ``cancelling`` for 
up to 10 minutes
+        before it settles as ``cancelled`` — so this only *requests* 
cancellation, it does not
+        wait for it. If ``execution_timeout`` is set shorter than ``timeout``, 
the scheduler's
+        deferral timeout fires first: the task is failed with 
``TaskDeferralTimeout`` before the
+        trigger ever times out, ``execute_complete`` is never called, and this 
cancellation path
+        does not run. Defaults to 24 hours, which is the SLA for OpenAI Batch 
API.

Review Comment:
   `on_kill` now goes through `_cancel_batch_quietly`, and the timeout branch 
in `OpenAIHook.wait_for_batch` logs a warning on a failed cancel and still 
raises `OpenAIBatchTimeout`. Both have tests for the failing-cancel case, so 
the sync path has the same protection and "mirroring the synchronous path" now 
holds.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to