You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "KlarenceNicolasCatalan (via GitHub)" <gi...@apache.org> on 2025/10/03 01:39:27 UTC
[PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
KlarenceNicolasCatalan opened a new pull request, #56351:
URL: https://github.com/apache/airflow/pull/56351
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
### **Why**
---
This pull request is a revised version of the pull request #55660 and so it is also based on issue #54379
**Why another PR**?
Due to the changes made in the previous pull request ( #55660 ), its design has deviated from the original PR. Therefore, it necessitated a change in PR following the new design and interaction with the user.
This PR's goal is **still the same** compared to the last one, however, its execution is now a bit different as **the modal is removed** and is replaced by a checkbox. The checkbox still serves the same purpose to prevent a running task instance from clearing, but without necessitating the user to read another prompt/ pop-up, and urging the user to make the decision before the dialog confirm instead of after.
### **What**
---
**Difference of this PR compared to PR** #55660 :
- Pop-up confirm modal is removed
- Modal is replaced by a checkbox in the clear task dialog
- Checkbox is checked (true) by default
This PR uses the same code for the backend flag from #55660 to enable the functionalities of the checkbox.
Here is a video example of how the checkbox works:
https://github.com/user-attachments/assets/526c4a2d-1021-4e8e-9da6-8886e2e93bcf
Here is what happens when the checkbox is unchecked and goes back to the default behavior:
https://github.com/user-attachments/assets/e064877f-3bf9-41aa-b102-50c86ce31dfa
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #56351:
URL: https://github.com/apache/airflow/pull/56351#discussion_r2488803676
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -793,12 +793,16 @@ 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,
- )
+ try:
+ clear_task_instances(
+ task_instances,
+ session,
+ DagRunState.QUEUED if reset_dag_runs else False,
+ run_on_latest_version=body.run_on_latest_version,
+ prevent_running_task=body.prevent_running_task,
+ )
+ except AirflowClearRunningTaskException as e:
+ raise HTTPException(status.HTTP_400_BAD_REQUEST, str(e)) from e
Review Comment:
I wonder if this should raise e.g. 409 instead. 400 implies the client should fix the request, but in this case the request itself is OK, it’s just the target task instances are in a state that cannot fulfill the request.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "KlarenceNicolasCatalan (via GitHub)" <gi...@apache.org>.
KlarenceNicolasCatalan commented on code in PR #56351:
URL: https://github.com/apache/airflow/pull/56351#discussion_r2488945615
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -793,12 +793,16 @@ 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,
- )
+ try:
+ clear_task_instances(
+ task_instances,
+ session,
+ DagRunState.QUEUED if reset_dag_runs else False,
+ run_on_latest_version=body.run_on_latest_version,
+ prevent_running_task=body.prevent_running_task,
+ )
+ except AirflowClearRunningTaskException as e:
+ raise HTTPException(status.HTTP_400_BAD_REQUEST, str(e)) from e
Review Comment:
Now that you say it, 409 does also make sense since it can mean that the state of the task is the reason for the exception. I just thought that 400 means that the client failed to clear the task as per request or something like that, so I went with 400. If that is the case, should I replace the 400 error code for a 409?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #56351:
URL: https://github.com/apache/airflow/pull/56351#discussion_r2435512562
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -773,13 +775,26 @@ def post_clear_task_instances(
end_date=body.end_date,
)
+ params = inspect.signature(clear_task_instances).parameters
+ kwargs = {
+ "run_on_latest_version": body.run_on_latest_version,
+ }
+
+ # Only include this argument if the function supports it
+ if "prevent_running_task" in params:
+ kwargs["prevent_running_task"] = body.prevent_running_task
Review Comment:
May I ask why do we need to check the params of `clear_task_instances` at runtime? Thanks.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #56351:
URL: https://github.com/apache/airflow/pull/56351#issuecomment-3559919146
Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional contributions.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "KlarenceNicolasCatalan (via GitHub)" <gi...@apache.org>.
KlarenceNicolasCatalan commented on code in PR #56351:
URL: https://github.com/apache/airflow/pull/56351#discussion_r2437703342
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -773,13 +775,26 @@ def post_clear_task_instances(
end_date=body.end_date,
)
+ params = inspect.signature(clear_task_instances).parameters
+ kwargs = {
+ "run_on_latest_version": body.run_on_latest_version,
+ }
+
+ # Only include this argument if the function supports it
+ if "prevent_running_task" in params:
+ kwargs["prevent_running_task"] = body.prevent_running_task
Review Comment:
There were multiple assertion errors that faults the passing of `prevent_running_task` in `clear_task_instances`. Even when in the method `clear_task_instances` in taskinstance.py was made optional or `None` in its parameters, I still get the same assertion error from the tests. I think it was caused by having passed/ written the `prevent_running_task` variable when the `clear_task_instances` method was called, and so the test sees that I've passed 5 arguments instead of 4. So, I made it check the params.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #56351:
URL: https://github.com/apache/airflow/pull/56351#discussion_r2488959635
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -793,12 +793,16 @@ 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,
- )
+ try:
+ clear_task_instances(
+ task_instances,
+ session,
+ DagRunState.QUEUED if reset_dag_runs else False,
+ run_on_latest_version=body.run_on_latest_version,
+ prevent_running_task=body.prevent_running_task,
+ )
+ except AirflowClearRunningTaskException as e:
+ raise HTTPException(status.HTTP_400_BAD_REQUEST, str(e)) from e
Review Comment:
Let’s change it to 409 (if there are other opinions we can change again)
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi merged PR #56351:
URL: https://github.com/apache/airflow/pull/56351
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "KlarenceNicolasCatalan (via GitHub)" <gi...@apache.org>.
KlarenceNicolasCatalan commented on code in PR #56351:
URL: https://github.com/apache/airflow/pull/56351#discussion_r2488140601
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -792,13 +793,22 @@ def post_clear_task_instances(
only_running=body.only_running,
)
+ params = inspect.signature(clear_task_instances).parameters
+ kwargs = {
+ "run_on_latest_version": body.run_on_latest_version,
+ }
+
+ # Only include this argument if the function supports it
+ if "prevent_running_task" in params:
+ kwargs["prevent_running_task"] = body.prevent_running_task
Review Comment:
Got it, thanks for this !
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "KlarenceNicolasCatalan (via GitHub)" <gi...@apache.org>.
KlarenceNicolasCatalan commented on PR #56351:
URL: https://github.com/apache/airflow/pull/56351#issuecomment-3540319030
Hello! This comment is a friendly ping for a review whenever someone is free. Sorry for the sudden notification.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #56351:
URL: https://github.com/apache/airflow/pull/56351#discussion_r2486282442
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/task_instances.py:
##########
@@ -792,13 +793,22 @@ def post_clear_task_instances(
only_running=body.only_running,
)
+ params = inspect.signature(clear_task_instances).parameters
+ kwargs = {
+ "run_on_latest_version": body.run_on_latest_version,
+ }
+
+ # Only include this argument if the function supports it
+ if "prevent_running_task" in params:
+ kwargs["prevent_running_task"] = body.prevent_running_task
Review Comment:
After double check, we don't need `inspect` to check `clear_task_instances`.
We just need to fix the test like following, FYI: https://github.com/apache/airflow/pull/57123/commits/2c38bdb3c0a7c801d23aa43162c6b92dd7e1f194
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "KlarenceNicolasCatalan (via GitHub)" <gi...@apache.org>.
KlarenceNicolasCatalan commented on PR #56351:
URL: https://github.com/apache/airflow/pull/56351#issuecomment-3494211368
Here is a video of the behavior as of the current commit:
https://github.com/user-attachments/assets/473015ce-b89a-49a8-9028-9a466f78500b
Here is a video of the default behavior of the clear task instance when "prevent running task" is unchecked:
https://github.com/user-attachments/assets/18d1b7b1-3ed2-4b2b-b143-7e5eeefa1796
And here are the screenshots:
<img width="1920" height="945" alt="chrome_MtgB3S9xOc" src="https://github.com/user-attachments/assets/67416a8b-aa34-4953-a4a0-a6829c54fc66" />
<img width="1920" height="945" alt="chrome_S4KjiGbG2Y" src="https://github.com/user-attachments/assets/7da4aee1-f431-416f-9e3c-b886d70aaf2d" />
<img width="1920" height="945" alt="chrome_Nuiy8eNYTx" src="https://github.com/user-attachments/assets/18ffc5c9-7227-4bd6-a0d6-a3eaa18bfdde" />
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "RoyLee1224 (via GitHub)" <gi...@apache.org>.
RoyLee1224 commented on PR #56351:
URL: https://github.com/apache/airflow/pull/56351#issuecomment-3561048190
It seems that the recent changes in this PR introduced some TypeScript compilation errors and ESLint issues in `src/airflow/ui/src/queries/useClearTaskInstances.ts.` Seems like this is currently breaking the UI build.
Errors encountered:
```
TypeScript Error: Property 'body' does not exist on type '{ detail?: unknown; }'.
ESLint Error: Unnecessary boolean literal compare (for prevent_running_task === true).
ESLint Error: Expected property shorthand.
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 commented on code in PR #56351:
URL: https://github.com/apache/airflow/pull/56351#discussion_r2425277111
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -95,6 +95,7 @@
from airflow.utils.span_status import SpanStatus
from airflow.utils.sqlalchemy import ExecutorConfigType, ExtendedJSON, UtcDateTime
from airflow.utils.state import DagRunState, State, TaskInstanceState
+from typing import Optional
Review Comment:
```suggestion
```
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -195,6 +196,7 @@ def clear_task_instances(
session: Session,
dag_run_state: DagRunState | Literal[False] = DagRunState.QUEUED,
run_on_latest_version: bool = False,
+ prevent_running_task: Optional[bool] = None,
Review Comment:
```suggestion
prevent_running_task: bool | None = None,
```
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -215,15 +217,32 @@ def clear_task_instances(
"""
task_instance_ids: list[str] = []
from airflow.models.dagbag import DBDagBag
+ from airflow.exceptions import AirflowClearRunningTaskException
scheduler_dagbag = DBDagBag(load_op_links=False)
for ti in tis:
task_instance_ids.append(ti.id)
ti.prepare_db_for_next_try(session)
- if ti.state == TaskInstanceState.RUNNING:
- # If a task is cleared when running, set its state to RESTARTING so that
- # the task is terminated and becomes eligible for retry.
- ti.state = TaskInstanceState.RESTARTING
+
+ #Task instance state checks:
+ is_running = ti.state == TaskInstanceState.RUNNING
+ is_queued = ti.state == TaskInstanceState.QUEUED
+ is_scheduled = ti.state == TaskInstanceState.SCHEDULED
Review Comment:
```suggestion
is_transitional = ti.state in {
TaskInstanceState.RUNNING,
TaskInstanceState.QUEUED,
TaskInstanceState.SCHEDULED,
}
```
##########
airflow-core/src/airflow/models/taskinstance.py:
##########
@@ -215,15 +217,32 @@ def clear_task_instances(
"""
task_instance_ids: list[str] = []
from airflow.models.dagbag import DBDagBag
+ from airflow.exceptions import AirflowClearRunningTaskException
scheduler_dagbag = DBDagBag(load_op_links=False)
for ti in tis:
task_instance_ids.append(ti.id)
ti.prepare_db_for_next_try(session)
- if ti.state == TaskInstanceState.RUNNING:
- # If a task is cleared when running, set its state to RESTARTING so that
- # the task is terminated and becomes eligible for retry.
- ti.state = TaskInstanceState.RESTARTING
+
+ #Task instance state checks:
+ is_running = ti.state == TaskInstanceState.RUNNING
+ is_queued = ti.state == TaskInstanceState.QUEUED
+ is_scheduled = ti.state == TaskInstanceState.SCHEDULED
+
+ if is_running or is_queued or is_scheduled:
+ if prevent_running_task and is_running:
+ raise AirflowClearRunningTaskException("AirflowClearRunningTaskException_RUNNING: Task is running, stopping attempt to clear.")
+ # Prevents the task from re-running and clearing when prevent_running_task and is_running is True.
+
+ elif prevent_running_task and (is_queued or is_scheduled):
+ raise AirflowClearRunningTaskException("AirflowClearRunningTaskException_QUEUED: Task is about to run or is scheduled to run, stopping attempt to clear.")
+ # Prevents the task from re-running and clearing when prevent_running_task is True and sends a warning toast.
Review Comment:
```suggestion
if is_transitional:
raise AirflowClearRunningTaskException("Disable 'prevent_running_task' to proceed, or wait until the task is not running, queued, or scheduled state.")
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #56351:
URL: https://github.com/apache/airflow/pull/56351#issuecomment-3387019839
Hmm. I think the UX could be improved.
When there is a pending task instance, we should show a warning and then have a checkbox to confirm that the user does in fact want to clear the existing tasks.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #56351:
URL: https://github.com/apache/airflow/pull/56351#discussion_r2449307791
##########
airflow-core/src/airflow/ui/src/queries/useClearTaskInstances.ts:
##########
@@ -46,14 +49,49 @@ export const useClearTaskInstances = ({
const queryClient = useQueryClient();
const { t: translate } = useTranslation("dags");
- const onError = (error: Error) => {
- toaster.create({
- description: error.message,
- title: translate("dags:runAndTaskActions.clear.error", { type: translate("taskInstance_one") }),
- type: "error",
- });
+ const onError = (error: unknown) => {
+ // Narrow the type safely
+ if (typeof error === "object" && error !== null) {
+ const apiError = error as ApiError;
+
+ const detail = typeof apiError.detail === "string" ? apiError.detail : "";
+ const ifDetailIsIncluded =
+ typeof detail === "string" && detail.includes("AirflowClearRunningTaskException");
+
+ if (detail !== "" && ifDetailIsIncluded === true) {
Review Comment:
```suggestion
if (detail.includes("AirflowClearRunningTaskException")) {
```
I feel like you can simplify this
##########
airflow-core/src/airflow/ui/src/queries/useClearTaskInstances.ts:
##########
@@ -46,14 +49,49 @@ export const useClearTaskInstances = ({
const queryClient = useQueryClient();
const { t: translate } = useTranslation("dags");
- const onError = (error: Error) => {
- toaster.create({
- description: error.message,
- title: translate("dags:runAndTaskActions.clear.error", { type: translate("taskInstance_one") }),
- type: "error",
- });
+ const onError = (error: unknown) => {
+ // Narrow the type safely
+ if (typeof error === "object" && error !== null) {
+ const apiError = error as ApiError;
+
+ const detail = typeof apiError.detail === "string" ? apiError.detail : "";
+ const ifDetailIsIncluded =
+ typeof detail === "string" && detail.includes("AirflowClearRunningTaskException");
+
+ if (detail !== "" && ifDetailIsIncluded === true) {
Review Comment:
Additionally, only the description is changing. So let's make that a variable and then we only need to call toaster.create() once.
##########
airflow-core/src/airflow/ui/public/i18n/locales/en/dags.json:
##########
@@ -63,7 +63,12 @@
"past": "Past",
"queueNew": "Queue up new tasks",
"runOnLatestVersion": "Run with latest bundle version",
- "upstream": "Upstream"
+ "upstream": "Upstream",
+ "preventRunningTasks": "Prevent rerun if task is running"
+ },
+ "confirmationDialog": {
+ "title": " Cannot Clear Task Instance",
Review Comment:
We shouldn't have a space here. If it's needed, lets add padding via styles
##########
airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceConfirmationDialog.tsx:
##########
@@ -0,0 +1,126 @@
+
+import { useEffect, useState, useCallback } from "react";
+import { VStack, Icon, Text, Spinner } from "@chakra-ui/react";
+import { GoAlertFill } from "react-icons/go";
+import { useTranslation } from "react-i18next";
+import { Button, Dialog } from "src/components/ui";
+import { useClearTaskInstancesDryRun } from "src/queries/useClearTaskInstancesDryRun";
+import { getRelativeTime } from "src/utils/datetimeUtils";
+
+type Props = {
+ readonly dagDetails?: {
+ dagId: string;
+ dagRunId: string;
+ downstream?: boolean;
+ future?: boolean;
+ mapIndex?: number;
+ onlyFailed?: boolean;
+ past?: boolean;
+ taskId: string;
+ upstream?: boolean;
+ };
+ readonly onClose: () => void;
+ readonly onConfirm?: () => void;
+ readonly open: boolean;
+ readonly preventRunningTask: boolean;
+};
+
+const ClearTaskInstanceConfirmationDialog = ({
+ dagDetails,
+ onClose,
+ onConfirm,
+ open,
+ preventRunningTask,
+}: Props) => {
+ const { t: translate } = useTranslation();
+ const { data, isFetching } = useClearTaskInstancesDryRun({
+ dagId: dagDetails?.dagId ?? "",
+ options: {
+ enabled: open && Boolean(dagDetails),
+ gcTime: 0,
+ refetchOnMount: "always",
+ refetchOnWindowFocus: false,
+ staleTime: 0,
+ },
+ requestBody: {
+ dag_run_id: dagDetails?.dagRunId ?? "",
+ include_downstream: dagDetails?.downstream,
+ include_future: dagDetails?.future,
+ include_past: dagDetails?.past,
+ include_upstream: dagDetails?.upstream,
+ only_failed: dagDetails?.onlyFailed,
+ task_ids: [[dagDetails?.taskId ?? "", dagDetails?.mapIndex ?? 0]],
+ },
+ });
+
+ const [isReady, setIsReady] = useState(false);
+
+ const handleConfirm = useCallback(() => {
+ if (onConfirm) onConfirm();
+ onClose();
+ }, [onConfirm, onClose]);
+
+ const taskCurrentState = data?.task_instances?.[0]?.state;
+
+ useEffect(() => {
+ if (!isFetching && open && data) {
+ const isInTriggeringState =
+ taskCurrentState === "queued" || taskCurrentState === "scheduled";
+
+ if (!preventRunningTask || !isInTriggeringState) {
+ handleConfirm();
+ } else {
+ setIsReady(true);
+ }
+ }
+ }, [isFetching, data, open, handleConfirm, taskCurrentState, preventRunningTask]);
+
+ return (
+ <Dialog.Root lazyMount onOpenChange={onClose} open={open}>
+ <Dialog.Content backdrop>
+ {isFetching ? (
+ // Loading State — keeps the dialog mounted during fetch
+ <VStack align="center" gap={3} justify="center" py={8}>
+ <Spinner size="lg" />
+ <Text color="gray.600" fontSize="md">
+ {translate("common:loadingTaskDetails", "Loading task details…")}
Review Comment:
Let's use the semantic token like `fg.solid` and then remove the backup translation text
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Checkbox before clear task confirmation to prevent rerun of tasks in 'Running' states. [airflow]
Posted by "KlarenceNicolasCatalan (via GitHub)" <gi...@apache.org>.
KlarenceNicolasCatalan commented on PR #56351:
URL: https://github.com/apache/airflow/pull/56351#issuecomment-3482988654
Bumping this.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org