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/12/04 17:44:49 UTC
[PR] Add basic Dag Run Details page [airflow]
bbovenzi opened a new pull request, #44656:
URL: https://github.com/apache/airflow/pull/44656
Flesh out the Dag Run Details page with a basic header and three tabs for a list of Task Instances, Events filtered to that dag run and Code. Also clicking on a Task Instance will go to a TI Details page which will be built next.
<img width="1011" alt="Screenshot 2024-12-04 at 12 39 58 PM" src="https://github.com/user-attachments/assets/de16c9ba-d064-423b-be0f-9d12fe7d3e7b">
---
**^ 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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1876394863
##########
airflow/ui/src/pages/Run/TaskInstances.tsx:
##########
@@ -0,0 +1,117 @@
+/*!
+ * 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, Link } from "@chakra-ui/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import dayjs from "dayjs";
+import { Link as RouterLink, useParams } from "react-router-dom";
+
+import { useTaskInstanceServiceGetTaskInstances } from "openapi/queries";
+import type { TaskInstanceResponse } from "openapi/requests/types.gen";
+import { DataTable } from "src/components/DataTable";
+import { useTableURLState } from "src/components/DataTable/useTableUrlState";
+import { ErrorAlert } from "src/components/ErrorAlert";
+import Time from "src/components/Time";
+import { Status } from "src/components/ui";
+
+const columns: Array<ColumnDef<TaskInstanceResponse>> = [
+ {
+ accessorKey: "task_display_name",
+ cell: ({ row: { original } }) => (
+ <Link asChild color="fg.info" fontWeight="bold">
+ <RouterLink
+ to={`/dags/${original.dag_id}/runs/${original.dag_run_id}/tasks/${original.task_id}${original.map_index > -1 ? `?map_index=${original.map_index}` : ""}`}
+ >
+ {original.task_display_name}
+ </RouterLink>
+ </Link>
+ ),
+ header: "Task ID",
+ },
+ {
+ accessorKey: "map_index",
+ header: "Map Index",
+ },
+ {
+ accessorKey: "try_number",
+ enableSorting: false,
+ header: "Try Number",
+ },
+ {
+ accessorKey: "state",
+ cell: ({
+ row: {
+ original: { state },
+ },
+ }) => <Status state={state}>{state}</Status>,
+ header: () => "State",
+ },
+ {
+ accessorKey: "operator",
+ enableSorting: false,
+ header: "Operator",
+ },
+ {
+ accessorKey: "start_date",
+ cell: ({ row: { original } }) => <Time datetime={original.start_date} />,
+ header: "Start Date",
+ },
+ {
+ accessorKey: "end_date",
+ cell: ({ row: { original } }) => <Time datetime={original.end_date} />,
+ header: "End Date",
+ },
+ {
+ cell: ({ row: { original } }) =>
+ `${dayjs.duration(dayjs(original.end_date).diff(original.start_date)).asSeconds().toFixed(2)}s`,
Review Comment:
`0.00s`
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on PR #44656:
URL: https://github.com/apache/airflow/pull/44656#issuecomment-2523916324
> One way to handle mapped task instances might be to pass `map_index` as a query parameter in the URL and then handle it. Below is a rough approach but this could be discussed in a separate issue since this will involve URL changes.
Updated everything to accept `map_index=X` search param or to at least forward the param around. Also, I realized we can just use `useTaskInstanceServiceGetMappedTaskInstance` and pass `-1` for regular task instances.
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "shubhamraj-git (via GitHub)" <gi...@apache.org>.
shubhamraj-git commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1874954949
##########
airflow/ui/src/pages/TaskInstance/Header.tsx:
##########
@@ -0,0 +1,82 @@
+/*!
+ * 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, Flex, Heading, HStack, SimpleGrid, Text } from "@chakra-ui/react";
+import dayjs from "dayjs";
+import { MdOutlineModeComment, MdOutlineTask } from "react-icons/md";
+
+import type { TaskInstanceResponse } from "openapi/requests/types.gen";
+import { Stat } from "src/components/Stat";
+import Time from "src/components/Time";
+import { Status } from "src/components/ui";
+
+export const Header = ({
+ taskInstance,
+}: {
+ readonly taskInstance: TaskInstanceResponse;
+}) => (
+ <Box borderColor="border" borderRadius={8} borderWidth={1} p={2}>
+ <Flex alignItems="center" justifyContent="space-between" mb={2}>
+ <HStack alignItems="center" gap={2}>
+ <MdOutlineTask size="1.75rem" />
+ <Heading size="lg">
+ <strong>Task Instance: </strong>
+ {taskInstance.task_display_name}{" "}
+ <Time datetime={taskInstance.start_date} />
+ </Heading>
+ <Status state={taskInstance.state ?? undefined}>
Review Comment:
since it will automatically pass undefined when taskInstance.state is not defined, is using ?? was for some explicit case?
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1876382048
##########
airflow/ui/src/components/ui/Status.tsx:
##########
@@ -28,12 +28,13 @@ import { stateColor } from "src/utils/stateColor";
type StatusValue = DagRunState | TaskInstanceState;
export type StatusProps = {
- state?: StatusValue;
+ state: StatusValue | null;
} & ChakraStatus.RootProps;
export const Status = React.forwardRef<HTMLDivElement, StatusProps>(
({ children, state, ...rest }, ref) => {
- const colorPalette = state === undefined ? "info" : stateColor[state];
+ // "null" is actually a string on stateColor
+ const colorPalette = stateColor[state ?? "null"];
Review Comment:
Shall we call this "created" perhaps? (I _might_ be making this change to the server side too, but it won't be universal just yet, so maybe we leave this as it is
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1876179351
##########
airflow/ui/src/pages/TaskInstance/Header.tsx:
##########
@@ -0,0 +1,82 @@
+/*!
+ * 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, Flex, Heading, HStack, SimpleGrid, Text } from "@chakra-ui/react";
+import dayjs from "dayjs";
+import { MdOutlineModeComment, MdOutlineTask } from "react-icons/md";
+
+import type { TaskInstanceResponse } from "openapi/requests/types.gen";
+import { Stat } from "src/components/Stat";
+import Time from "src/components/Time";
+import { Status } from "src/components/ui";
+
+export const Header = ({
+ taskInstance,
+}: {
+ readonly taskInstance: TaskInstanceResponse;
+}) => (
+ <Box borderColor="border" borderRadius={8} borderWidth={1} p={2}>
+ <Flex alignItems="center" justifyContent="space-between" mb={2}>
+ <HStack alignItems="center" gap={2}>
+ <MdOutlineTask size="1.75rem" />
+ <Heading size="lg">
+ <strong>Task Instance: </strong>
+ {taskInstance.task_display_name}{" "}
+ <Time datetime={taskInstance.start_date} />
+ </Heading>
+ <Status state={taskInstance.state ?? undefined}>
Review Comment:
Actually, yeah `<Status` should just handle it instead.
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1876393351
##########
airflow/ui/src/pages/Run/Header.tsx:
##########
@@ -0,0 +1,75 @@
+/*!
+ * 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, Flex, Heading, HStack, SimpleGrid, Text } from "@chakra-ui/react";
+import dayjs from "dayjs";
+import { FiBarChart } from "react-icons/fi";
+import { MdOutlineModeComment } from "react-icons/md";
+
+import type { DAGRunResponse } from "openapi/requests/types.gen";
+import { RunTypeIcon } from "src/components/RunTypeIcon";
+import { Stat } from "src/components/Stat";
+import Time from "src/components/Time";
+import { Status } from "src/components/ui";
+
+export const Header = ({ dagRun }: { readonly dagRun: DAGRunResponse }) => (
+ <Box borderColor="border" borderRadius={8} borderWidth={1} p={2}>
+ <Flex alignItems="center" justifyContent="space-between" mb={2}>
+ <HStack alignItems="center" gap={2}>
+ <FiBarChart size="1.75rem" />
Review Comment:
Feather icon: https://react-icons.github.io/react-icons/icons/fi/
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1876388956
##########
airflow/ui/src/components/ui/Status.tsx:
##########
@@ -28,12 +28,13 @@ import { stateColor } from "src/utils/stateColor";
type StatusValue = DagRunState | TaskInstanceState;
export type StatusProps = {
- state?: StatusValue;
+ state: StatusValue | null;
} & ChakraStatus.RootProps;
export const Status = React.forwardRef<HTMLDivElement, StatusProps>(
({ children, state, ...rest }, ref) => {
- const colorPalette = state === undefined ? "info" : stateColor[state];
+ // "null" is actually a string on stateColor
+ const colorPalette = stateColor[state ?? "null"];
Review Comment:
The entire `stateColor` object is a placeholder for now. So I'm happy to update it if we change it on the server side too.
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi merged PR #44656:
URL: https://github.com/apache/airflow/pull/44656
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1876384453
##########
airflow/ui/src/pages/Dag/Dag.tsx:
##########
@@ -0,0 +1,71 @@
+/*!
+ * 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 { useParams } from "react-router-dom";
+
+import {
+ useDagServiceGetDagDetails,
+ useDagsServiceRecentDagRuns,
+} from "openapi/queries";
+import { DetailsLayout } from "src/layouts/Details/DetailsLayout";
+
+import { Header } from "./Header";
+
+const tabs = [
+ { label: "Overview", value: "" },
+ { label: "Runs", value: "runs" },
+ { label: "Tasks", value: "tasks" },
+ { label: "Events", value: "events" },
+ { label: "Code", value: "code" },
+];
+
+export const Dag = () => {
+ const { dagId = "" } = useParams();
+
+ const {
+ data: dag,
+ error,
+ isLoading,
+ } = useDagServiceGetDagDetails({
+ dagId,
+ });
+
+ // TODO: replace with with a list dag runs by dag id request
+ const {
+ data: runsData,
+ error: runsError,
+ isLoading: isLoadingRuns,
+ } = useDagsServiceRecentDagRuns({ dagIdPattern: dagId }, undefined, {
+ enabled: Boolean(dagId),
+ });
+
+ const runs =
+ runsData?.dags.find((dagWithRuns) => dagWithRuns.dag_id === dagId)
Review Comment:
Does this work (calling a function) if `runsData` is nil?
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1870889270
##########
airflow/ui/src/pages/TaskInstance/TaskInstance.tsx:
##########
@@ -0,0 +1,88 @@
+/*!
+ * 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 { LiaSlashSolid } from "react-icons/lia";
+import { useParams, Link as RouterLink } from "react-router-dom";
+
+import {
+ useDagServiceGetDagDetails,
+ useTaskInstanceServiceGetTaskInstance,
+} from "openapi/queries";
+import { Breadcrumb } from "src/components/ui";
+import { DetailsLayout } from "src/layouts/Details/DetailsLayout";
+
+import { Header } from "./Header";
+
+const tabs = [
+ { label: "Logs", value: "" },
+ { label: "Events", value: "events" },
+ { label: "XCom", value: "xcom" },
+ { label: "Code", value: "code" },
+ { label: "Details", value: "details" },
+];
+
+export const TaskInstance = () => {
+ const { dagId = "", runId = "", taskId = "" } = useParams();
+
+ const {
+ data: taskInstance,
+ error,
+ isLoading,
+ } = useTaskInstanceServiceGetTaskInstance({
Review Comment:
mapped task instances need to be handled here since trying to fetch a mapped task instance without map_index using this API will result in error. Sample example dag run that shows this error.
http://localhost:8000/webapp/dags/example_dynamic_task_mapping_with_no_taskflow_operators/runs/manual__2024-12-03T09:53:48.394009+00:00/tasks/add_one
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1870852002
##########
airflow/ui/src/pages/TaskInstance/Header.tsx:
##########
@@ -0,0 +1,82 @@
+/*!
+ * 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, Flex, Heading, HStack, SimpleGrid, Text } from "@chakra-ui/react";
+import dayjs from "dayjs";
+import { MdOutlineModeComment, MdOutlineTask } from "react-icons/md";
+
+import type { TaskInstanceResponse } from "openapi/requests/types.gen";
+import { Stat } from "src/components/Stat";
+import Time from "src/components/Time";
+import { Status } from "src/components/ui";
+
+export const Header = ({
+ taskInstance,
+}: {
+ readonly taskInstance: TaskInstanceResponse;
+}) => (
+ <Box borderColor="border" borderRadius={8} borderWidth={1} p={2}>
+ <Flex alignItems="center" justifyContent="space-between" mb={2}>
+ <HStack alignItems="center" gap={2}>
+ <MdOutlineTask size="1.75rem" />
+ <Heading size="lg">
+ <strong>Task Instance: </strong>
+ {taskInstance.task_display_name}{" "}
+ <Time datetime={taskInstance.start_date} />
+ </Heading>
+ <Status state={taskInstance.state ?? undefined}>
+ {taskInstance.state}
+ </Status>
+ <Flex>
+ <div />
+ </Flex>
+ </HStack>
+ </Flex>
+ {taskInstance.note === null ||
+ taskInstance.note.length === 0 ? undefined : (
+ <Flex alignItems="flex-start" justifyContent="space-between" mr={16}>
+ <MdOutlineModeComment size="3rem" />
+ <Text fontSize="sm" ml={3}>
+ {taskInstance.note}
+ </Text>
+ </Flex>
+ )}
+ <SimpleGrid columns={4} gap={4} my={2}>
Review Comment:
For tasks with higher try number greater than 1 this pushes duration to it's own row making the header slightly larger. Perhaps this can be dynamic or 6 to accommodate all attributes
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1876394863
##########
airflow/ui/src/pages/Run/TaskInstances.tsx:
##########
@@ -0,0 +1,117 @@
+/*!
+ * 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, Link } from "@chakra-ui/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import dayjs from "dayjs";
+import { Link as RouterLink, useParams } from "react-router-dom";
+
+import { useTaskInstanceServiceGetTaskInstances } from "openapi/queries";
+import type { TaskInstanceResponse } from "openapi/requests/types.gen";
+import { DataTable } from "src/components/DataTable";
+import { useTableURLState } from "src/components/DataTable/useTableUrlState";
+import { ErrorAlert } from "src/components/ErrorAlert";
+import Time from "src/components/Time";
+import { Status } from "src/components/ui";
+
+const columns: Array<ColumnDef<TaskInstanceResponse>> = [
+ {
+ accessorKey: "task_display_name",
+ cell: ({ row: { original } }) => (
+ <Link asChild color="fg.info" fontWeight="bold">
+ <RouterLink
+ to={`/dags/${original.dag_id}/runs/${original.dag_run_id}/tasks/${original.task_id}${original.map_index > -1 ? `?map_index=${original.map_index}` : ""}`}
+ >
+ {original.task_display_name}
+ </RouterLink>
+ </Link>
+ ),
+ header: "Task ID",
+ },
+ {
+ accessorKey: "map_index",
+ header: "Map Index",
+ },
+ {
+ accessorKey: "try_number",
+ enableSorting: false,
+ header: "Try Number",
+ },
+ {
+ accessorKey: "state",
+ cell: ({
+ row: {
+ original: { state },
+ },
+ }) => <Status state={state}>{state}</Status>,
+ header: () => "State",
+ },
+ {
+ accessorKey: "operator",
+ enableSorting: false,
+ header: "Operator",
+ },
+ {
+ accessorKey: "start_date",
+ cell: ({ row: { original } }) => <Time datetime={original.start_date} />,
+ header: "Start Date",
+ },
+ {
+ accessorKey: "end_date",
+ cell: ({ row: { original } }) => <Time datetime={original.end_date} />,
+ header: "End Date",
+ },
+ {
+ cell: ({ row: { original } }) =>
+ `${dayjs.duration(dayjs(original.end_date).diff(original.start_date)).asSeconds().toFixed(2)}s`,
Review Comment:
It will default to using `now`. So if both are null then its 0.00s
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1876389918
##########
airflow/ui/src/pages/Dag/Dag.tsx:
##########
@@ -0,0 +1,71 @@
+/*!
+ * 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 { useParams } from "react-router-dom";
+
+import {
+ useDagServiceGetDagDetails,
+ useDagsServiceRecentDagRuns,
+} from "openapi/queries";
+import { DetailsLayout } from "src/layouts/Details/DetailsLayout";
+
+import { Header } from "./Header";
+
+const tabs = [
+ { label: "Overview", value: "" },
+ { label: "Runs", value: "runs" },
+ { label: "Tasks", value: "tasks" },
+ { label: "Events", value: "events" },
+ { label: "Code", value: "code" },
+];
+
+export const Dag = () => {
+ const { dagId = "" } = useParams();
+
+ const {
+ data: dag,
+ error,
+ isLoading,
+ } = useDagServiceGetDagDetails({
+ dagId,
+ });
+
+ // TODO: replace with with a list dag runs by dag id request
+ const {
+ data: runsData,
+ error: runsError,
+ isLoading: isLoadingRuns,
+ } = useDagsServiceRecentDagRuns({ dagIdPattern: dagId }, undefined, {
+ enabled: Boolean(dagId),
+ });
+
+ const runs =
+ runsData?.dags.find((dagWithRuns) => dagWithRuns.dag_id === dagId)
Review Comment:
That's why on the line below we default to an empty array.
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on PR #44656:
URL: https://github.com/apache/airflow/pull/44656#issuecomment-2519482854
The components and pages can later have clipboard button in relevant places to copy dag_id, run_id, task_id etc. which was present in the old UI and was handy.
https://www.chakra-ui.com/docs/components/clipboard
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1870852002
##########
airflow/ui/src/pages/TaskInstance/Header.tsx:
##########
@@ -0,0 +1,82 @@
+/*!
+ * 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, Flex, Heading, HStack, SimpleGrid, Text } from "@chakra-ui/react";
+import dayjs from "dayjs";
+import { MdOutlineModeComment, MdOutlineTask } from "react-icons/md";
+
+import type { TaskInstanceResponse } from "openapi/requests/types.gen";
+import { Stat } from "src/components/Stat";
+import Time from "src/components/Time";
+import { Status } from "src/components/ui";
+
+export const Header = ({
+ taskInstance,
+}: {
+ readonly taskInstance: TaskInstanceResponse;
+}) => (
+ <Box borderColor="border" borderRadius={8} borderWidth={1} p={2}>
+ <Flex alignItems="center" justifyContent="space-between" mb={2}>
+ <HStack alignItems="center" gap={2}>
+ <MdOutlineTask size="1.75rem" />
+ <Heading size="lg">
+ <strong>Task Instance: </strong>
+ {taskInstance.task_display_name}{" "}
+ <Time datetime={taskInstance.start_date} />
+ </Heading>
+ <Status state={taskInstance.state ?? undefined}>
+ {taskInstance.state}
+ </Status>
+ <Flex>
+ <div />
+ </Flex>
+ </HStack>
+ </Flex>
+ {taskInstance.note === null ||
+ taskInstance.note.length === 0 ? undefined : (
+ <Flex alignItems="flex-start" justifyContent="space-between" mr={16}>
+ <MdOutlineModeComment size="3rem" />
+ <Text fontSize="sm" ml={3}>
+ {taskInstance.note}
+ </Text>
+ </Flex>
+ )}
+ <SimpleGrid columns={4} gap={4} my={2}>
Review Comment:
For tasks with higher try number greater than 1 this pushes duration to it's own row making the header slightly larger. Perhaps `columns` can be dynamic or 6 to accommodate all attributes
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1870800832
##########
airflow/ui/src/pages/Events/Events.tsx:
##########
@@ -121,13 +131,14 @@ export const Events = () => {
limit: pagination.pageSize,
offset: pagination.pageIndex * pagination.pageSize,
orderBy,
+ runId,
Review Comment:
`taskId` can also be passed to the Events API which when available will filter out events for the task in the task instance's events tab.
```suggestion
runId,
taskId,
```
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on PR #44656:
URL: https://github.com/apache/airflow/pull/44656#issuecomment-2519606200
One way to handle mapped task instances might be to pass `map_index` as a query parameter in the URL and then handle it. Below is a rough approach but this could be discussed in a separate issue since this will involve URL changes.
```patch
diff --git a/airflow/ui/src/pages/Events/Events.tsx b/airflow/ui/src/pages/Events/Events.tsx
index 60663aefec..d311471252 100644
--- a/airflow/ui/src/pages/Events/Events.tsx
+++ b/airflow/ui/src/pages/Events/Events.tsx
@@ -18,7 +18,7 @@
*/
import { Box } from "@chakra-ui/react";
import type { ColumnDef } from "@tanstack/react-table";
-import { useParams } from "react-router-dom";
+import { useSearchParams, useParams } from "react-router-dom";
import { useEventLogServiceGetEventLogs } from "openapi/queries";
import type { EventLogResponse } from "openapi/requests/types.gen";
@@ -113,6 +113,8 @@ const eventsColumn = (
export const Events = () => {
const { dagId, runId, taskId } = useParams();
+ const [searchParams, setSearchParams] = useSearchParams();
+ const mapIndex = searchParams.get("map_index");
const { setTableURLState, tableURLState } = useTableURLState({
sorting: [{ desc: true, id: "when" }],
});
@@ -132,6 +134,8 @@ export const Events = () => {
offset: pagination.pageIndex * pagination.pageSize,
orderBy,
runId,
+ taskId,
+ mapIndex,
});
return (
diff --git a/airflow/ui/src/pages/Run/TaskInstances.tsx b/airflow/ui/src/pages/Run/TaskInstances.tsx
index e96ff55d46..4e4127cdfc 100644
--- a/airflow/ui/src/pages/Run/TaskInstances.tsx
+++ b/airflow/ui/src/pages/Run/TaskInstances.tsx
@@ -35,7 +35,7 @@ const columns: Array<ColumnDef<TaskInstanceResponse>> = [
cell: ({ row: { original } }) => (
<Link asChild color="fg.info" fontWeight="bold">
<RouterLink
- to={`/dags/${original.dag_id}/runs/${original.dag_run_id}/tasks/${original.task_id}`}
+ to={`/dags/${original.dag_id}/runs/${original.dag_run_id}/tasks/${original.task_id}?map_index=${original.map_index}`}
>
{original.task_display_name}
</RouterLink>
diff --git a/airflow/ui/src/pages/TaskInstance/TaskInstance.tsx b/airflow/ui/src/pages/TaskInstance/TaskInstance.tsx
index b9e41de93d..d0f5ca9930 100644
--- a/airflow/ui/src/pages/TaskInstance/TaskInstance.tsx
+++ b/airflow/ui/src/pages/TaskInstance/TaskInstance.tsx
@@ -17,37 +17,51 @@
* under the License.
*/
import { LiaSlashSolid } from "react-icons/lia";
-import { useParams, Link as RouterLink } from "react-router-dom";
+import {
+ useParams,
+ useSearchParams,
+ Link as RouterLink,
+} from "react-router-dom";
import {
useDagServiceGetDagDetails,
useTaskInstanceServiceGetTaskInstance,
+ useTaskInstanceServiceGetMappedTaskInstance,
} from "openapi/queries";
import { Breadcrumb } from "src/components/ui";
import { DetailsLayout } from "src/layouts/Details/DetailsLayout";
import { Header } from "./Header";
-const tabs = [
- { label: "Logs", value: "" },
- { label: "Events", value: "events" },
- { label: "XCom", value: "xcom" },
- { label: "Code", value: "code" },
- { label: "Details", value: "details" },
-];
-
export const TaskInstance = () => {
const { dagId = "", runId = "", taskId = "" } = useParams();
+ const [searchParams, setSearchParams] = useSearchParams();
+ const mapIndex = searchParams.get("map_index");
+
+ const tabs = [
+ { label: "Logs", value: "" },
+ { label: "Events", value: `events?map_index=${mapIndex}` },
+ { label: "XCom", value: `xcom?map_index=${mapIndex}` },
+ { label: "Code", value: `code?map_index=${mapIndex}` },
+ { label: "Details", value: `details?map_index=${mapIndex}` },
+ ];
const {
data: taskInstance,
error,
isLoading,
- } = useTaskInstanceServiceGetTaskInstance({
- dagId,
- dagRunId: runId,
- taskId,
- });
+ } = Boolean(mapIndex) && mapIndex > -1
+ ? useTaskInstanceServiceGetMappedTaskInstance({
+ dagId,
+ dagRunId: runId,
+ taskId,
+ mapIndex,
+ })
+ : useTaskInstanceServiceGetTaskInstance({
+ dagId,
+ dagRunId: runId,
+ taskId,
+ });
const {
data: dag,
```
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1876390022
##########
airflow/ui/src/pages/Run/Header.tsx:
##########
@@ -0,0 +1,75 @@
+/*!
+ * 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, Flex, Heading, HStack, SimpleGrid, Text } from "@chakra-ui/react";
+import dayjs from "dayjs";
+import { FiBarChart } from "react-icons/fi";
+import { MdOutlineModeComment } from "react-icons/md";
+
+import type { DAGRunResponse } from "openapi/requests/types.gen";
+import { RunTypeIcon } from "src/components/RunTypeIcon";
+import { Stat } from "src/components/Stat";
+import Time from "src/components/Time";
+import { Status } from "src/components/ui";
+
+export const Header = ({ dagRun }: { readonly dagRun: DAGRunResponse }) => (
+ <Box borderColor="border" borderRadius={8} borderWidth={1} p={2}>
+ <Flex alignItems="center" justifyContent="space-between" mb={2}>
+ <HStack alignItems="center" gap={2}>
+ <FiBarChart size="1.75rem" />
Review Comment:
What does the "Fi" prefix mean here out of interest?
--
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] Fill out Dag Run and Task Instance Details pages with Grid and Gantt buttons. [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #44656:
URL: https://github.com/apache/airflow/pull/44656#discussion_r1876393443
##########
airflow/ui/src/pages/Run/TaskInstances.tsx:
##########
@@ -0,0 +1,117 @@
+/*!
+ * 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, Link } from "@chakra-ui/react";
+import type { ColumnDef } from "@tanstack/react-table";
+import dayjs from "dayjs";
+import { Link as RouterLink, useParams } from "react-router-dom";
+
+import { useTaskInstanceServiceGetTaskInstances } from "openapi/queries";
+import type { TaskInstanceResponse } from "openapi/requests/types.gen";
+import { DataTable } from "src/components/DataTable";
+import { useTableURLState } from "src/components/DataTable/useTableUrlState";
+import { ErrorAlert } from "src/components/ErrorAlert";
+import Time from "src/components/Time";
+import { Status } from "src/components/ui";
+
+const columns: Array<ColumnDef<TaskInstanceResponse>> = [
+ {
+ accessorKey: "task_display_name",
+ cell: ({ row: { original } }) => (
+ <Link asChild color="fg.info" fontWeight="bold">
+ <RouterLink
+ to={`/dags/${original.dag_id}/runs/${original.dag_run_id}/tasks/${original.task_id}${original.map_index > -1 ? `?map_index=${original.map_index}` : ""}`}
+ >
+ {original.task_display_name}
+ </RouterLink>
+ </Link>
+ ),
+ header: "Task ID",
+ },
+ {
+ accessorKey: "map_index",
+ header: "Map Index",
+ },
+ {
+ accessorKey: "try_number",
+ enableSorting: false,
+ header: "Try Number",
+ },
+ {
+ accessorKey: "state",
+ cell: ({
+ row: {
+ original: { state },
+ },
+ }) => <Status state={state}>{state}</Status>,
+ header: () => "State",
+ },
+ {
+ accessorKey: "operator",
+ enableSorting: false,
+ header: "Operator",
+ },
+ {
+ accessorKey: "start_date",
+ cell: ({ row: { original } }) => <Time datetime={original.start_date} />,
+ header: "Start Date",
+ },
+ {
+ accessorKey: "end_date",
+ cell: ({ row: { original } }) => <Time datetime={original.end_date} />,
+ header: "End Date",
+ },
+ {
+ cell: ({ row: { original } }) =>
+ `${dayjs.duration(dayjs(original.end_date).diff(original.start_date)).asSeconds().toFixed(2)}s`,
Review Comment:
How does this behave if end_date And or start_date are null?
--
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