You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "guan404ming (via GitHub)" <gi...@apache.org> on 2025/04/21 03:47:38 UTC

[PR] AIP-38: merge Backfill and Trigger Dag Run [airflow]

guan404ming opened a new pull request, #49490:
URL: https://github.com/apache/airflow/pull/49490

   <!--
    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/
   -->
   
   ## Related Issue
   
   Closes #47576
   cc: @bbovenzi
   
   ## Why 
   
   - Backfill is too hidden in current UI
   
   ## How
   
   - Merge the model with the Trigger Dag Run
   - Minor change: adjust padding for model to let the space keep identical between the select and the form in the model
   
   https://github.com/user-attachments/assets/32dac8ef-7710-49c3-9c9a-111de09633e6
   
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
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] AIP-38: merge Backfill and Trigger Dag Run [airflow]

Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl commented on code in PR #49490:
URL: https://github.com/apache/airflow/pull/49490#discussion_r2052317776


##########
airflow-core/src/airflow/ui/src/components/TriggerDag/TriggerDAGModal.tsx:
##########
@@ -37,22 +45,72 @@ const TriggerDAGModal: React.FC<TriggerDAGModalProps> = ({
   isPaused,
   onClose,
   open,
-}) => (
-  <Dialog.Root lazyMount onOpenChange={onClose} open={open} size="xl" unmountOnExit>
-    <Dialog.Content backdrop>
-      <Dialog.Header paddingBottom={0}>
-        <VStack align="start" gap={4}>
-          <Heading size="xl">Trigger Dag - {dagDisplayName}</Heading>
-        </VStack>
-      </Dialog.Header>
-
-      <Dialog.CloseTrigger />
-
-      <Dialog.Body>
-        <TriggerDAGForm dagId={dagId} isPaused={isPaused} onClose={onClose} open={open} />
-      </Dialog.Body>
-    </Dialog.Content>
-  </Dialog.Root>
-);
+}) => {
+  const [runMode, setRunMode] = useState<RunMode>(RunMode.SINGLE);
+  const { data: dag } = useDagServiceGetDag(
+    {
+      dagId,
+    },
+    undefined,
+    {
+      enabled: open && runMode === RunMode.BACKFILL,
+    },
+  );
+
+  const hasSchedule = dag?.timetable_summary !== null;
+
+  useEffect(() => {

Review Comment:
   @bbovenzi / @pierrejeambrun I remember that using `useEffect()` is somehow "bad practice" - Maybe I am lagging a bit of understanding - is the use here OK or shall a different construct be used?



-- 
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] AIP-38: merge Backfill and Trigger Dag Run [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #49490:
URL: https://github.com/apache/airflow/pull/49490#discussion_r2052301170


##########
airflow-core/src/airflow/ui/src/components/TriggerDag/TriggerDAGModal.tsx:
##########
@@ -37,22 +45,62 @@ const TriggerDAGModal: React.FC<TriggerDAGModalProps> = ({
   isPaused,
   onClose,
   open,
-}) => (
-  <Dialog.Root lazyMount onOpenChange={onClose} open={open} size="xl" unmountOnExit>
-    <Dialog.Content backdrop>
-      <Dialog.Header paddingBottom={0}>
-        <VStack align="start" gap={4}>
-          <Heading size="xl">Trigger Dag - {dagDisplayName}</Heading>
-        </VStack>
-      </Dialog.Header>
-
-      <Dialog.CloseTrigger />
-
-      <Dialog.Body>
-        <TriggerDAGForm dagId={dagId} isPaused={isPaused} onClose={onClose} open={open} />
-      </Dialog.Body>
-    </Dialog.Content>
-  </Dialog.Root>
-);
+}) => {
+  const [runMode, setRunMode] = useState<RunMode>(RunMode.SINGLE);
+  const { data: dag } = useDagServiceGetDag(
+    {
+      dagId,
+    },
+    undefined,
+    {
+      enabled: open && runMode === RunMode.BACKFILL,
+    },
+  );
+
+  return (
+    <Dialog.Root lazyMount onOpenChange={onClose} open={open} size="xl" unmountOnExit>
+      <Dialog.Content backdrop>
+        <Dialog.Header paddingBottom={0}>
+          <VStack align="start" gap={2} width="100%">
+            <Heading size="xl">
+              {runMode === RunMode.SINGLE ? "Trigger DAG" : "Run Backfill"} - {dagDisplayName}
+            </Heading>
+          </VStack>
+        </Dialog.Header>
+
+        <Dialog.CloseTrigger />
+
+        <Dialog.Body>
+          <RadioCardRoot
+            my={4}
+            onChange={(event) => {
+              setRunMode((event.target as HTMLInputElement).value as RunMode);
+            }}
+            value={runMode}
+          >
+            <HStack align="stretch">

Review Comment:
   Thanks for reviewing~
   Sure, I've updated, please take another look.



-- 
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] AIP-38: merge Backfill and Trigger Dag Run [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49490:
URL: https://github.com/apache/airflow/pull/49490#issuecomment-2818375964

   Thanks for catching this~ I updated the implementation with loading and error fallback to prevent show glitch here and also remove the useEffect since it seems like not necessarily here.


-- 
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] AIP-38: merge Backfill and Trigger Dag Run [airflow]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #49490:
URL: https://github.com/apache/airflow/pull/49490#issuecomment-2818442876

   Thanks for testing and reviewing~


-- 
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] AIP-38: merge Backfill and Trigger Dag Run [airflow]

Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl commented on code in PR #49490:
URL: https://github.com/apache/airflow/pull/49490#discussion_r2052003726


##########
airflow-core/src/airflow/ui/src/components/TriggerDag/TriggerDAGModal.tsx:
##########
@@ -37,22 +45,62 @@ const TriggerDAGModal: React.FC<TriggerDAGModalProps> = ({
   isPaused,
   onClose,
   open,
-}) => (
-  <Dialog.Root lazyMount onOpenChange={onClose} open={open} size="xl" unmountOnExit>
-    <Dialog.Content backdrop>
-      <Dialog.Header paddingBottom={0}>
-        <VStack align="start" gap={4}>
-          <Heading size="xl">Trigger Dag - {dagDisplayName}</Heading>
-        </VStack>
-      </Dialog.Header>
-
-      <Dialog.CloseTrigger />
-
-      <Dialog.Body>
-        <TriggerDAGForm dagId={dagId} isPaused={isPaused} onClose={onClose} open={open} />
-      </Dialog.Body>
-    </Dialog.Content>
-  </Dialog.Root>
-);
+}) => {
+  const [runMode, setRunMode] = useState<RunMode>(RunMode.SINGLE);
+  const { data: dag } = useDagServiceGetDag(
+    {
+      dagId,
+    },
+    undefined,
+    {
+      enabled: open && runMode === RunMode.BACKFILL,
+    },
+  );
+
+  return (
+    <Dialog.Root lazyMount onOpenChange={onClose} open={open} size="xl" unmountOnExit>
+      <Dialog.Content backdrop>
+        <Dialog.Header paddingBottom={0}>
+          <VStack align="start" gap={2} width="100%">
+            <Heading size="xl">
+              {runMode === RunMode.SINGLE ? "Trigger DAG" : "Run Backfill"} - {dagDisplayName}
+            </Heading>
+          </VStack>
+        </Dialog.Header>
+
+        <Dialog.CloseTrigger />
+
+        <Dialog.Body>
+          <RadioCardRoot
+            my={4}
+            onChange={(event) => {
+              setRunMode((event.target as HTMLInputElement).value as RunMode);
+            }}
+            value={runMode}
+          >
+            <HStack align="stretch">

Review Comment:
   Backfill only makes sense if the DAG is scheduled. Can you please hide the backfill option if there is no regular schedule defined?



-- 
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] AIP-38: merge Backfill and Trigger Dag Run [airflow]

Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl merged PR #49490:
URL: https://github.com/apache/airflow/pull/49490


-- 
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] AIP-38: merge Backfill and Trigger Dag Run [airflow]

Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl commented on PR #49490:
URL: https://github.com/apache/airflow/pull/49490#issuecomment-2818285123

   Okay, looks all very cool. Just found one leftover "glitch" - as the trigger button is used in multiple places, it seems the initialization is not 100% consistent. When you click on the trigger button on the DAG overview (right hand side) then the dialog opens with both (normal as well as backfill) options also for not scheduled DAGs.
   Once you click on "backfill" the options dis-appears,
   
   See:
   ![image](https://github.com/user-attachments/assets/6698c366-b6d2-408c-b64b-fc500ec140d9)
   
   Can you handle also the other case where the dialog is used? Then in my view it is good to merge.


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