-
Notifications
You must be signed in to change notification settings - Fork 16.9k
Dag Run and Overview Tab Display Deadlines #62195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
imrichardwu
wants to merge
20
commits into
apache:main
Choose a base branch
from
imrichardwu:error-ui-frontend
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
e593169
Add FailedIcon component and DurationChart failed icon plugin
imrichardwu 6c32415
Add initial plugin files for AI provider with license information
imrichardwu e6bec47
Merge branch 'main' into error-ui-frontend
imrichardwu 5c7fd91
Add deadline management features to DAG UI
imrichardwu 9b2fd64
Add name and description fields to DeadlineAlert and related serializ…
imrichardwu d42cd59
Refactor deadline management in DAG UI: update DeadlineAlert fields, …
imrichardwu af27e2f
Enhance AllDeadlinesModal: add pagination support and update deadline…
imrichardwu 1e8cc1d
Merge branch 'main' into error-ui-frontend
imrichardwu 83b4e02
Enhance AllDeadlinesModal: increase dialog size and add backdrop padding
imrichardwu 3c14138
Merge branch 'main' into error-ui-frontend
imrichardwu c040737
Enhance DeadlineStatus: update icon colors for better visibility
imrichardwu 001bc71
Merge branch 'main' into error-ui-frontend
imrichardwu 1cb841c
Enhance Deadline Management: add completion rules, improve deadline a…
imrichardwu 60b3edb
Merge branch 'main' into error-ui-frontend
imrichardwu 445ce90
Enhance DeadlineAlertsBadge: include alert name in display and remove…
imrichardwu 20ee187
Enhance DeadlineAlertsBadge: display alert name conditionally and sim…
imrichardwu 2b6c629
Merge branch 'main' into error-ui-frontend
imrichardwu fd76b5b
remove python
imrichardwu ea9fd13
UI: Enhance deadline components with additional data handling and props
imrichardwu a425539
UI: Refactor alert handling to use alert IDs instead of names in dead…
imrichardwu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
airflow-core/src/airflow/ui/src/pages/Dag/DeadlineAlertsBadge.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /*! | ||
| * 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, Button, Separator, Text, VStack } from "@chakra-ui/react"; | ||
| import dayjs from "dayjs"; | ||
| import duration from "dayjs/plugin/duration"; | ||
| import relativeTime from "dayjs/plugin/relativeTime"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { FiClock } from "react-icons/fi"; | ||
|
|
||
| import { useDeadlinesServiceGetDagDeadlineAlerts } from "openapi/queries"; | ||
| import type { DeadlineAlertResponse } from "openapi/requests/types.gen"; | ||
| import { Popover } from "src/components/ui"; | ||
|
|
||
| dayjs.extend(duration); | ||
| dayjs.extend(relativeTime); | ||
|
|
||
| const AlertRow = ({ alert }: { readonly alert: DeadlineAlertResponse }) => { | ||
| const { t: translate } = useTranslation("dag"); | ||
| const reference = translate(`deadlineAlerts.referenceType.${alert.reference_type}`, { | ||
| defaultValue: alert.reference_type, | ||
| }); | ||
| const interval = dayjs.duration(alert.interval, "seconds").humanize(); | ||
|
|
||
| return ( | ||
| <Box py={2} width="100%"> | ||
| <Text color="fg.muted" fontSize="xs"> | ||
| {translate("deadlineAlerts.completionRule", { interval, reference })} | ||
| {Boolean(alert.name) && ( | ||
| <Text as="span" color="fg.subtle" fontSize="xs"> | ||
| {" "} | ||
| ({alert.name}) | ||
| </Text> | ||
| )} | ||
| </Text> | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| export const DeadlineAlertsBadge = ({ dagId }: { readonly dagId: string }) => { | ||
| const { t: translate } = useTranslation("dag"); | ||
|
|
||
| const { data } = useDeadlinesServiceGetDagDeadlineAlerts({ dagId }); | ||
|
|
||
| const alerts = data?.deadline_alerts ?? []; | ||
|
|
||
| if (alerts.length === 0) { | ||
| return undefined; | ||
| } | ||
|
|
||
| return ( | ||
| // eslint-disable-next-line jsx-a11y/no-autofocus | ||
| <Popover.Root autoFocus={false} lazyMount unmountOnExit> | ||
| <Popover.Trigger asChild> | ||
| <Button color="fg.info" size="xs" variant="outline"> | ||
| <FiClock /> | ||
| {translate("deadlineAlerts.count", { count: data?.total_entries ?? alerts.length })} | ||
| </Button> | ||
|
imrichardwu marked this conversation as resolved.
|
||
| </Popover.Trigger> | ||
|
imrichardwu marked this conversation as resolved.
|
||
| <Popover.Content css={{ "--popover-bg": "colors.bg.emphasized" }} maxWidth="360px" width="fit-content"> | ||
| <Popover.Arrow /> | ||
| <Popover.Body> | ||
| <Text fontWeight="bold" mb={1}> | ||
| {translate("deadlineAlerts.title")} | ||
| </Text> | ||
| <VStack gap={0} separator={<Separator />}> | ||
| {alerts.map((alert) => ( | ||
| <AlertRow alert={alert} key={alert.id} /> | ||
| ))} | ||
| </VStack> | ||
| </Popover.Body> | ||
| </Popover.Content> | ||
| </Popover.Root> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
airflow-core/src/airflow/ui/src/pages/Dag/Overview/AllDeadlinesModal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| /*! | ||
| * 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 { Heading, HStack, Separator, Skeleton, VStack } from "@chakra-ui/react"; | ||
| import { useState } from "react"; | ||
|
|
||
| import { useDagRunServiceGetDagRuns, useDeadlinesServiceGetDeadlines } from "openapi/queries"; | ||
| import type { DAGRunResponse, DagRunState, DeadlineAlertResponse } from "openapi/requests/types.gen"; | ||
| import { ErrorAlert } from "src/components/ErrorAlert"; | ||
| import { Dialog } from "src/components/ui"; | ||
| import { Pagination } from "src/components/ui/Pagination"; | ||
|
|
||
| import { DeadlineRow } from "./DeadlineRow"; | ||
|
|
||
| const PAGE_LIMIT = 10; | ||
|
|
||
| type AllDeadlinesModalProps = { | ||
| readonly alertMap: Map<string, DeadlineAlertResponse>; | ||
| readonly dagId: string; | ||
| readonly endDate: string; | ||
| readonly missed: boolean; | ||
| readonly onClose: () => void; | ||
| readonly open: boolean; | ||
| readonly refetchInterval: number | false; | ||
| readonly startDate: string; | ||
| readonly title: string; | ||
| }; | ||
|
|
||
| export const AllDeadlinesModal = ({ | ||
| alertMap, | ||
| dagId, | ||
| endDate, | ||
| missed, | ||
| onClose, | ||
| open, | ||
| refetchInterval, | ||
| startDate, | ||
| title, | ||
| }: AllDeadlinesModalProps) => { | ||
| const [page, setPage] = useState(1); | ||
| const offset = (page - 1) * PAGE_LIMIT; | ||
|
|
||
| const { data, error, isLoading } = useDeadlinesServiceGetDeadlines( | ||
| missed | ||
| ? { | ||
| dagId, | ||
| dagRunId: "~", | ||
| lastUpdatedAtGte: startDate, | ||
| lastUpdatedAtLte: endDate, | ||
| limit: PAGE_LIMIT, | ||
| missed: true, | ||
| offset, | ||
| orderBy: ["-last_updated_at"], | ||
| } | ||
| : { | ||
| dagId, | ||
| dagRunId: "~", | ||
| deadlineTimeGte: endDate, | ||
| limit: PAGE_LIMIT, | ||
| missed: false, | ||
| offset, | ||
| orderBy: ["deadline_time"], | ||
| }, | ||
| undefined, | ||
| { enabled: open, refetchInterval }, | ||
| ); | ||
|
|
||
| const { data: runsData } = useDagRunServiceGetDagRuns( | ||
| { dagId, limit: 100, runAfterGte: startDate, runAfterLte: endDate }, | ||
| undefined, | ||
| { enabled: open, refetchInterval }, | ||
| ); | ||
|
|
||
| const runStateMap = new Map<string, DagRunState>(); | ||
| const runMap = new Map<string, DAGRunResponse>(); | ||
|
|
||
| for (const run of runsData?.dag_runs ?? []) { | ||
| runStateMap.set(run.dag_run_id, run.state); | ||
| runMap.set(run.dag_run_id, run); | ||
| } | ||
|
|
||
| const deadlines = data?.deadlines ?? []; | ||
| const totalEntries = data?.total_entries ?? 0; | ||
|
|
||
| const getAlert = (alertId?: string | null) => | ||
| alertId !== undefined && alertId !== null ? alertMap.get(alertId) : undefined; | ||
|
|
||
| const onOpenChange = () => { | ||
| setPage(1); | ||
| onClose(); | ||
| }; | ||
|
|
||
| return ( | ||
| <Dialog.Root onOpenChange={onOpenChange} open={open} scrollBehavior="inside" size="lg"> | ||
| <Dialog.Content backdrop p={4}> | ||
| <Dialog.Header> | ||
| <Heading size="sm">{title}</Heading> | ||
| </Dialog.Header> | ||
| <Dialog.CloseTrigger /> | ||
| <Dialog.Body pb={2}> | ||
| <ErrorAlert error={error} /> | ||
| {isLoading ? ( | ||
| <VStack> | ||
| {Array.from({ length: PAGE_LIMIT }).map((_, idx) => ( | ||
| // eslint-disable-next-line react/no-array-index-key | ||
| <Skeleton height="36px" key={idx} width="100%" /> | ||
| ))} | ||
| </VStack> | ||
| ) : ( | ||
| <VStack gap={0} separator={<Separator />}> | ||
| {deadlines.map((dl) => ( | ||
| <DeadlineRow | ||
| alert={getAlert(dl.alert_id)} | ||
| deadline={dl} | ||
| key={dl.id} | ||
| run={runMap.get(dl.dag_run_id)} | ||
| runState={runStateMap.get(dl.dag_run_id)} | ||
| /> | ||
| ))} | ||
| </VStack> | ||
| )} | ||
| </Dialog.Body> | ||
| {totalEntries > PAGE_LIMIT ? ( | ||
| <Pagination.Root | ||
| count={totalEntries} | ||
| onPageChange={(event) => setPage(event.page)} | ||
| p={3} | ||
| page={page} | ||
| pageSize={PAGE_LIMIT} | ||
| > | ||
| <HStack justify="center"> | ||
| <Pagination.PrevTrigger /> | ||
| <Pagination.Items /> | ||
| <Pagination.NextTrigger /> | ||
| </HStack> | ||
| </Pagination.Root> | ||
| ) : undefined} | ||
| </Dialog.Content> | ||
| </Dialog.Root> | ||
| ); | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.