You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "bbovenzi (via GitHub)" <gi...@apache.org> on 2024/11/15 20:31:13 UTC

[PR] Init Dag Overview page with time range selector and failed tasks [airflow]

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

   Initialize the Dag Overview page with a timerange selector that will search for failed task instances in that range and show it as a button with the total count and the distribution of failed tis over the time range.
   
   In another PR: build the tasks page so clicking the button brings you somewhere useful.
   
   <img width="1188" alt="Screenshot 2024-11-15 at 3 28 51 PM" src="https://github.com/user-attachments/assets/2fab0ad2-dfb1-49ab-86d6-f8eb4059d627">
   <img width="1194" alt="Screenshot 2024-11-15 at 3 28 58 PM" src="https://github.com/user-attachments/assets/fda32999-d7d3-49cd-a49e-a39bf758aa5c">
   
   
   <!-- 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 [newsfragments](https://github.com/apache/airflow/tree/main/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] Init Dag Overview page with time range selector and failed tasks [airflow]

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

   If `chart.js` has everything that we need in terms of variety of charts and customization option, indeed I think that would be simpler to use. 👍 


-- 
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] Init Dag Overview page with time range selector and failed tasks [airflow]

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


##########
airflow/ui/package.json:
##########
@@ -17,18 +17,20 @@
   },
   "dependencies": {
     "@chakra-ui/anatomy": "^2.2.2",
-    "@chakra-ui/react": "^3.0.2",
+    "@chakra-ui/react": "^3.1.1",
     "@codemirror/lang-json": "^6.0.1",
     "@emotion/react": "^11.13.3",
     "@tanstack/react-query": "^5.52.1",
     "@tanstack/react-table": "^8.20.1",
-    "@uiw/react-codemirror": "^4.23.5",
     "@uiw/codemirror-themes-all": "^4.23.5",
+    "@uiw/react-codemirror": "^4.23.5",
     "axios": "^1.7.7",
     "chakra-react-select": "6.0.0-next.2",
+    "chart.js": "^4.4.6",

Review Comment:
   I tried using echarts for this and it was very difficult to size and position it properly and without typescript errors. And chartjs has better documentation.



-- 
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] Init Dag Overview page with time range selector and failed tasks [airflow]

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

   Also this just makes me realize that `http://localhost:29091/ui/dags/recent_dag_runs?dag_id_pattern=xxxxx` endpoint should most certainly also support a `dag_id` query params or `dag_ids`.
   
   I am affraid that using a `pattern` like this could end up matching multiple dags while we are really trying to get the dag_runs from a specific dag like 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] Init Dag Overview page with time range selector and failed tasks [airflow]

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


##########
airflow/ui/package.json:
##########
@@ -17,18 +17,20 @@
   },
   "dependencies": {
     "@chakra-ui/anatomy": "^2.2.2",
-    "@chakra-ui/react": "^3.0.2",
+    "@chakra-ui/react": "^3.1.1",
     "@codemirror/lang-json": "^6.0.1",
     "@emotion/react": "^11.13.3",
     "@tanstack/react-query": "^5.52.1",
     "@tanstack/react-table": "^8.20.1",
-    "@uiw/react-codemirror": "^4.23.5",
     "@uiw/codemirror-themes-all": "^4.23.5",
+    "@uiw/react-codemirror": "^4.23.5",
     "axios": "^1.7.7",
     "chakra-react-select": "6.0.0-next.2",
+    "chart.js": "^4.4.6",

Review Comment:
   If chart.js has everything that we need in terms of variety of charts and customization option, indeed I think that would be simpler to use. 👍.
   
   > Just curious with chartjs since legacy UI used echarts for many charts. On first look the chartjs API looks similar to echarts. Were there any issues with echarts that led to this decision?
   
   I don't think so, it's just that `chart.js` has really good defaults and is really easy to use in comparison, maybe this is what led Brent to try `chart.js`
   
   



-- 
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] Init Dag Overview page with time range selector and failed tasks [airflow]

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


##########
airflow/ui/package.json:
##########
@@ -17,18 +17,20 @@
   },
   "dependencies": {
     "@chakra-ui/anatomy": "^2.2.2",
-    "@chakra-ui/react": "^3.0.2",
+    "@chakra-ui/react": "^3.1.1",
     "@codemirror/lang-json": "^6.0.1",
     "@emotion/react": "^11.13.3",
     "@tanstack/react-query": "^5.52.1",
     "@tanstack/react-table": "^8.20.1",
-    "@uiw/react-codemirror": "^4.23.5",
     "@uiw/codemirror-themes-all": "^4.23.5",
+    "@uiw/react-codemirror": "^4.23.5",
     "axios": "^1.7.7",
     "chakra-react-select": "6.0.0-next.2",
+    "chart.js": "^4.4.6",

Review Comment:
   If chart.js has everything that we need in terms of variety of charts and customization option, indeed I think that would be simpler to use. 👍.
   
   > Just curious with chartjs since legacy UI used echarts for many charts. On first look the chartjs API looks similar to echarts. Were there any issues with echarts that led to this decision?
   
   I don't think so, it's just that `chart.js` has really good defaults and is really easy to use in comparison I think.
   
   



-- 
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] Init Dag Overview page with time range selector and failed tasks [airflow]

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


##########
airflow/ui/src/pages/DagsList/Dag/Overview/Overview.tsx:
##########
@@ -0,0 +1,96 @@
+/*!
+ * 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.
+ */
+import { Box, HStack, Badge, Text, Skeleton } from "@chakra-ui/react";
+import dayjs from "dayjs";
+import { useState } from "react";
+import { Link, useLocation, useParams } from "react-router-dom";
+
+import { useTaskInstanceServiceGetTaskInstances } from "openapi/queries";
+import TimeRangeSelector from "src/components/TimeRangeSelector";
+import { pluralize } from "src/utils";
+import { stateColor } from "src/utils/stateColor";
+
+import { Chart } from "./Chart";
+
+const defaultHour = "8";
+
+export const Overview = () => {
+  const { dagId } = useParams();
+
+  const now = dayjs();
+  const [startDate, setStartDate] = useState(
+    now.subtract(Number(defaultHour), "hour").toISOString(),
+  );
+  const [endDate, setEndDate] = useState(now.toISOString());
+
+  const { data: failedTasks, isLoading } =
+    useTaskInstanceServiceGetTaskInstances({
+      dagId: dagId ?? "",
+      dagRunId: "~",
+      logicalDateGte: startDate,
+      logicalDateLte: endDate,
+      state: ["failed"],
+    });
+
+  const location = useLocation();
+
+  // TODO actually link to task instances list
+  return (
+    <Box m={4}>
+      <Box my={2}>
+        <TimeRangeSelector
+          defaultValue={defaultHour}
+          endDate={endDate}
+          setEndDate={setEndDate}
+          setStartDate={setStartDate}
+          startDate={startDate}
+        />
+      </Box>
+      {failedTasks?.total_entries !== undefined &&
+      failedTasks.total_entries > 0 ? (

Review Comment:
   I think we should still display the graph with a flat `0` line if there are no failed task. In its current state the graph is just not displayed with can be a little surprising.



-- 
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] Init Dag Overview page with time range selector and failed tasks [airflow]

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


##########
airflow/ui/src/pages/DagsList/Dag/Overview/Overview.tsx:
##########
@@ -0,0 +1,96 @@
+/*!
+ * 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.
+ */
+import { Box, HStack, Badge, Text, Skeleton } from "@chakra-ui/react";
+import dayjs from "dayjs";
+import { useState } from "react";
+import { Link, useLocation, useParams } from "react-router-dom";
+
+import { useTaskInstanceServiceGetTaskInstances } from "openapi/queries";
+import TimeRangeSelector from "src/components/TimeRangeSelector";
+import { pluralize } from "src/utils";
+import { stateColor } from "src/utils/stateColor";
+
+import { Chart } from "./Chart";
+
+const defaultHour = "8";
+
+export const Overview = () => {
+  const { dagId } = useParams();
+
+  const now = dayjs();
+  const [startDate, setStartDate] = useState(
+    now.subtract(Number(defaultHour), "hour").toISOString(),
+  );
+  const [endDate, setEndDate] = useState(now.toISOString());
+
+  const { data: failedTasks, isLoading } =
+    useTaskInstanceServiceGetTaskInstances({
+      dagId: dagId ?? "",
+      dagRunId: "~",
+      logicalDateGte: startDate,
+      logicalDateLte: endDate,
+      state: ["failed"],
+    });
+
+  const location = useLocation();
+
+  // TODO actually link to task instances list
+  return (
+    <Box m={4}>
+      <Box my={2}>
+        <TimeRangeSelector
+          defaultValue={defaultHour}
+          endDate={endDate}
+          setEndDate={setEndDate}
+          setStartDate={setStartDate}
+          startDate={startDate}
+        />
+      </Box>
+      {failedTasks?.total_entries !== undefined &&
+      failedTasks.total_entries > 0 ? (

Review Comment:
   Currently, we just don't display the button at all if there are no failed tasks in that range. So theres no need for a quick link to those failed 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] Init Dag Overview page with time range selector and failed tasks [airflow]

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


##########
airflow/ui/package.json:
##########
@@ -17,18 +17,20 @@
   },
   "dependencies": {
     "@chakra-ui/anatomy": "^2.2.2",
-    "@chakra-ui/react": "^3.0.2",
+    "@chakra-ui/react": "^3.1.1",
     "@codemirror/lang-json": "^6.0.1",
     "@emotion/react": "^11.13.3",
     "@tanstack/react-query": "^5.52.1",
     "@tanstack/react-table": "^8.20.1",
-    "@uiw/react-codemirror": "^4.23.5",
     "@uiw/codemirror-themes-all": "^4.23.5",
+    "@uiw/react-codemirror": "^4.23.5",
     "axios": "^1.7.7",
     "chakra-react-select": "6.0.0-next.2",
+    "chart.js": "^4.4.6",

Review Comment:
   Just curious with chartjs since legacy UI used echarts for many charts. On first look the chartjs API looks similar to echarts. Were there any issues with echarts that led to this decision?



-- 
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] Init Dag Overview page with time range selector and failed tasks [airflow]

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


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