pierrejeambrun commented on code in PR #55660:
URL: https://github.com/apache/airflow/pull/55660#discussion_r2382417076


##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/task_instances.py:
##########
@@ -202,6 +202,7 @@ class ClearTaskInstancesBody(StrictBaseModel):
         description="(Experimental) Run on the latest bundle version of the 
dag after "
         "clearing the task instances.",
     )
+    is_running_message: bool = False

Review Comment:
   We should probably change the naming here. "force", "force_running", 
"bypass_running" or something else, `message` makes me think of  a 'string'



##########
airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.tsx:
##########
@@ -170,6 +171,14 @@ const ClearTaskInstanceDialog = ({ onClose, open, 
taskInstance }: Props) => {
                 
{translate("dags:runAndTaskActions.options.runOnLatestVersion")}
               </Checkbox>
             ) : undefined}
+            <Checkbox
+              checked={isRunningMessage}
+              style={{ marginRight: "auto"}}
+              onCheckedChange={(event) => 
setIsRunningMessage(Boolean(event.checked))}
+            >
+              {/* Will need approval for translation changes, please remember 
*/}
+              
{translate("dags:runAndTaskActions.options.preventRunningTasks")} 

Review Comment:
   you can remove this comment, it's fine this is for 3.1+, freeze will be gone.



##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -770,12 +770,19 @@ def post_clear_task_instances(
         )
 
     if not dry_run:
-        clear_task_instances(
-            task_instances,
-            session,
-            DagRunState.QUEUED if reset_dag_runs else False,
-            run_on_latest_version=body.run_on_latest_version,
-        )
+        if body.is_running_message:
+            for ti in task_instances:
+                ti.is_running_message = body.is_running_message

Review Comment:
   dynamically adding an attribute to the ti model like this is not recommended.
   
   You just need to pass down the `force` param to `clear_task_instances` and 
handle there what to do.



##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -770,12 +770,19 @@ def post_clear_task_instances(
         )
 
     if not dry_run:
-        clear_task_instances(
-            task_instances,
-            session,
-            DagRunState.QUEUED if reset_dag_runs else False,
-            run_on_latest_version=body.run_on_latest_version,
-        )
+        if body.is_running_message:
+            for ti in task_instances:
+                ti.is_running_message = body.is_running_message
+        
+        try:
+            clear_task_instances(
+                task_instances,
+                session,
+                DagRunState.QUEUED if reset_dag_runs else False,
+                run_on_latest_version=body.run_on_latest_version,
+            )
+        except ValueError as e:

Review Comment:
   did you encountered an unhandled ValueError? Those should crash the server 
if they are unexpected. (only throw 400 if this is actually client's falt)



-- 
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