Skip to content

Commit

Permalink
Fix 404 taskInstance errors and split into two tables
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrejeambrun committed Sep 22, 2022
1 parent 7aacba2 commit 7b4a8a0
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 45 deletions.
81 changes: 44 additions & 37 deletions airflow/www/static/js/dag/details/taskInstance/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
Tbody,
Tr,
Td,
Heading,
Divider,
} from '@chakra-ui/react';

import { finalStatesMap } from 'src/utils';
Expand All @@ -34,8 +34,8 @@ import { SimpleStatus } from 'src/dag/StatusBox';
import Time from 'src/components/Time';
import { ClipboardText } from 'src/components/Clipboard';
import type { Task, TaskInstance, TaskState } from 'src/types';
import useTaskInstance from 'src/api/useTaskInstance';
import DatasetUpdateEvents from './DatasetUpdateEvents';
import useTaskInstance from '../../../api/useTaskInstance';

interface Props {
instance: TaskInstance;
Expand All @@ -57,16 +57,21 @@ const Details = ({ instance, group, dagId }: Props) => {
mapIndex,
} = instance;

const { data: apiTI } = useTaskInstance({
dagId, dagRunId: runId, taskId, mapIndex, enabled: true,
});
const {
isMapped,
tooltip,
operator,
hasOutletDatasets,
} = group;

const { data: apiTI } = useTaskInstance({
dagId,
dagRunId: runId,
taskId,
mapIndex,
enabled: !isGroup && !isMapped,
});

const numMap = finalStatesMap();
let numMapped = 0;
if (isGroup) {
Expand Down Expand Up @@ -109,21 +114,12 @@ const Details = ({ instance, group, dagId }: Props) => {
const isOverall = (isMapped || isGroup) && 'Overall ';
return (
<Flex flexWrap="wrap" justifyContent="space-between">
<Table variant="striped">
<Tbody>
{tooltip && (
<Tr>
<Td colSpan={2}>{tooltip}</Td>
</Tr>
)}
{state === 'deferred' && (
<>
<Tr borderBottomWidth={2} borderBottomColor="gray.300">
<Td>
<Heading size="sm">Triggerer info</Heading>
</Td>
<Td />
</Tr>
{state === 'deferred' && (
<>
<Text as="strong">Triggerer info</Text>
<Divider my={2} />
<Table variant="striped" mb={3}>
<Tbody>
<Tr>
<Td>Trigger class</Td>
<Td>{`${apiTI?.trigger?.classpath}`}</Td>
Expand All @@ -140,17 +136,20 @@ const Details = ({ instance, group, dagId }: Props) => {
<Td>Latest triggerer heartbeat</Td>
<Td>{`${apiTI?.triggererJob?.latestHeartbeat}`}</Td>
</Tr>
</>
</Tbody>
</Table>
</>
)}

<Text as="strong">Task Instance Details</Text>
<Divider my={2} />
<Table variant="striped">
<Tbody>
{tooltip && (
<Tr>
<Td colSpan={2}>{tooltip}</Td>
</Tr>
)}
<Tr
borderBottomWidth={2}
borderBottomColor="gray.300"
>
<Td>
<Heading size="sm">Task Instance Details</Heading>
</Td>
<Td />
</Tr>
<Tr>
<Td>
{isOverall}
Expand All @@ -173,16 +172,20 @@ const Details = ({ instance, group, dagId }: Props) => {
</Td>
</Tr>
)}
{summary.length > 0 && (
summary
)}
{summary.length > 0 && summary}
<Tr>
<Td>{taskIdTitle}</Td>
<Td><ClipboardText value={taskId} /></Td>
<Td>
<ClipboardText value={taskId} />
</Td>
</Tr>
<Tr>
<Td>Run ID</Td>
<Td><Text whiteSpace="nowrap"><ClipboardText value={runId} /></Text></Td>
<Td>
<Text whiteSpace="nowrap">
<ClipboardText value={runId} />
</Text>
</Td>
</Tr>
{mapIndex !== undefined && (
<Tr>
Expand All @@ -206,13 +209,17 @@ const Details = ({ instance, group, dagId }: Props) => {
{startDate && (
<Tr>
<Td>Started</Td>
<Td><Time dateTime={startDate} /></Td>
<Td>
<Time dateTime={startDate} />
</Td>
</Tr>
)}
{endDate && isStateFinal && (
<Tr>
<Td>Ended</Td>
<Td><Time dateTime={endDate} /></Td>
<Td>
<Time dateTime={endDate} />
</Td>
</Tr>
)}
</Tbody>
Expand Down
16 changes: 8 additions & 8 deletions airflow/www/static/js/dag/details/taskInstance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ const TaskInstance = ({
{/* Mapped Task Instances Tab */}
{
isMappedTaskSummary && (
<TabPanel>
<MappedInstances
dagId={dagId}
runId={runId}
taskId={taskId}
onRowClicked={(row) => onSelect({ runId, taskId, mapIndex: row.values.mapIndex })}
/>
</TabPanel>
<TabPanel>
<MappedInstances
dagId={dagId}
runId={runId}
taskId={taskId}
onRowClicked={(row) => onSelect({ runId, taskId, mapIndex: row.values.mapIndex })}
/>
</TabPanel>
)
}
</TabPanels>
Expand Down

0 comments on commit 7b4a8a0

Please sign in to comment.