Skip to content

Commit

Permalink
incorporate run step history into step matrix (#10478)
Browse files Browse the repository at this point in the history
* incorporate run step history into step matrix

* further cleanup
  • Loading branch information
prha committed Nov 14, 2022
1 parent 2657cbb commit c5c7422
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 78 deletions.
Expand Up @@ -16,7 +16,9 @@ const MIN_SPAN_WIDTH = 8;
export enum PartitionState {
MISSING = 'missing',
SUCCESS = 'success',
SUCCESS_MISSING = 'success_missing', // states where the run succeeded in the past for a given step, but is missing for the last run
FAILURE = 'failure',
FAILURE_MISSING = 'failure_missing', // states where the run failed in the past for a given step, but is missing for the last run
QUEUED = 'queued',
STARTED = 'started',
}
Expand Down
Expand Up @@ -22,6 +22,7 @@ import {buildLayout} from '../gantt/GanttChartLayout';
import {useViewport} from '../gantt/useViewport';
import {linkToRunEvent} from '../runs/RunUtils';
import {RunFilterToken} from '../runs/RunsFilterInput';
import {RunStatus} from '../types/globalTypes';
import {MenuLink} from '../ui/MenuLink';
import {repoAddressToSelector} from '../workspace/repoAddressToSelector';
import {RepoAddress} from '../workspace/types';
Expand All @@ -45,7 +46,6 @@ import {
PARTITION_MATRIX_SOLID_HANDLE_FRAGMENT,
MatrixStep,
PartitionRuns,
StatusSquareFinalColor,
useMatrixData,
MatrixData,
} from './useMatrixData';
Expand Down Expand Up @@ -422,11 +422,12 @@ const PartitionSquare: React.FC<{
if (!runsLoaded) {
squareStatus = 'loading';
} else if (step) {
squareStatus = (StatusSquareFinalColor[step.color] || step.color).toLowerCase();
squareStatus = step.color.toLowerCase();
} else if (runs.length === 0) {
squareStatus = 'empty';
} else {
squareStatus = runs[runs.length - 1].status.toLowerCase();
const runStatus = runs[runs.length - 1].status;
squareStatus = runStatus === RunStatus.CANCELED ? 'failure' : runStatus.toLowerCase();
}

const content = (
Expand Down
60 changes: 7 additions & 53 deletions js_modules/dagit/packages/core/src/partitions/RunMatrixUtils.tsx
Expand Up @@ -6,7 +6,9 @@ export const BOX_SIZE = 32;

export const STEP_STATUS_COLORS = {
SUCCESS: Colors.Green500,
SUCCESS_SKIPPED: Colors.Green200,
FAILURE: Colors.Red500,
FAILURE_SKIPPED: Colors.Red200,
SKIPPED: Colors.Yellow500,
IN_PROGRESS: '#eee',
};
Expand Down Expand Up @@ -123,79 +125,31 @@ export const GridColumn = styled.div<{
background: ${STEP_STATUS_COLORS.SUCCESS};
}
}
&.success-skipped {
&:before {
background: linear-gradient(
135deg,
${STEP_STATUS_COLORS.SUCCESS} 49%,
${STEP_STATUS_COLORS.SKIPPED} 51%
);
}
}
&.success-failure {
&:before {
background: linear-gradient(
135deg,
${STEP_STATUS_COLORS.SUCCESS} 49%,
${STEP_STATUS_COLORS.FAILURE} 51%
);
}
}
&.failure {
&:before {
background: ${STEP_STATUS_COLORS.FAILURE};
}
}
&.failure-success {
&.success-missing {
&:before {
background: linear-gradient(
135deg,
${STEP_STATUS_COLORS.FAILURE} 49%,
${STEP_STATUS_COLORS.SUCCESS} 51%
);
background: ${STEP_STATUS_COLORS.SUCCESS_SKIPPED};
}
}
&.failure-skipped {
&.failure-missing {
&:before {
background: linear-gradient(
135deg,
${STEP_STATUS_COLORS.FAILURE} 49%,
${STEP_STATUS_COLORS.SKIPPED} 51%
);
background: ${STEP_STATUS_COLORS.FAILURE_SKIPPED};
}
}
&.failure-blank {
&:before {
background: linear-gradient(
135deg,
${STEP_STATUS_COLORS.FAILURE} 49%,
rgba(150, 150, 150, 0.3) 51%
);
background: ${STEP_STATUS_COLORS.FAILURE_SKIPPED};
}
}
&.skipped {
&:before {
background: ${STEP_STATUS_COLORS.SKIPPED};
}
}
&.skipped-success {
&:before {
background: linear-gradient(
135deg,
${STEP_STATUS_COLORS.SKIPPED} 49%,
${STEP_STATUS_COLORS.SUCCESS} 51%
);
}
}
&.skipped-failure {
&:before {
background: linear-gradient(
135deg,
${STEP_STATUS_COLORS.SKIPPED} 49%,
${STEP_STATUS_COLORS.FAILURE} 51%
);
}
}
}
`;

Expand Down
50 changes: 28 additions & 22 deletions js_modules/dagit/packages/core/src/partitions/useMatrixData.tsx
Expand Up @@ -13,26 +13,7 @@ import {StepEventStatus} from '../types/globalTypes';
import {PartitionMatrixSolidHandleFragment} from './types/PartitionMatrixSolidHandleFragment';
import {PartitionMatrixStepRunFragment} from './types/PartitionMatrixStepRunFragment';

type StatusSquareColor =
| 'SUCCESS'
| 'FAILURE'
| 'SKIPPED'
| 'MISSING'
| 'FAILURE-SUCCESS'
| 'FAILURE-SKIPPED'
| 'SUCCESS-FAILURE'
| 'SUCCESS-SKIPPED'
| 'SKIPPED-SUCCESS'
| 'SKIPPED-FAILURE';

export const StatusSquareFinalColor: {[key: string]: StatusSquareColor} = {
'FAILURE-SUCCESS': 'SUCCESS',
'SKIPPED-SUCCESS': 'SUCCESS',
'SUCCESS-FAILURE': 'FAILURE',
'SKIPPED-FAILURE': 'FAILURE',
'FAILURE-SKIPPED': 'SKIPPED',
'SUCCESS-SKIPPED': 'SKIPPED',
};
type StatusSquareColor = 'SUCCESS' | 'FAILURE' | 'MISSING' | 'FAILURE-MISSING' | 'SUCCESS-MISSING';

export interface PartitionRuns {
name: string;
Expand All @@ -55,6 +36,8 @@ export interface MatrixStep {
unix: number;
}

const MISSING_STEP_STATUSES = new Set([StepEventStatus.IN_PROGRESS, StepEventStatus.SKIPPED]);

function getStartTime(a: PartitionMatrixStepRunFragment) {
return a.startTime || 0;
}
Expand Down Expand Up @@ -107,14 +90,37 @@ function buildMatrixData(
isStepKeyForNode(node.name, stats.stepKey),
)?.status;

if (!lastRunStepStatus || lastRunStepStatus === StepEventStatus.IN_PROGRESS) {
let previousRunStatus;
if (
partition.runs.length > 1 &&
(!lastRunStepStatus || MISSING_STEP_STATUSES.has(lastRunStepStatus))
) {
let idx = partition.runs.length - 2;
while (idx >= 0 && !previousRunStatus) {
const currRun = partition.runs[idx];
const currRunStatus = currRun.stepStats.find((stats) =>
isStepKeyForNode(node.name, stats.stepKey),
)?.status;
if (currRunStatus && !MISSING_STEP_STATUSES.has(currRunStatus)) {
previousRunStatus = currRunStatus;
break;
}
idx--;
}
}

if (!lastRunStepStatus && !previousRunStatus) {
return blankState;
}

const color: StatusSquareColor =
!lastRunStepStatus || MISSING_STEP_STATUSES.has(lastRunStepStatus)
? (`${previousRunStatus}-MISSING` as StatusSquareColor)
: (lastRunStepStatus as StatusSquareColor);
return {
name: node.name,
unix: getStartTime(lastRun),
color: lastRunStepStatus,
color,
};
});
return {
Expand Down

0 comments on commit c5c7422

Please sign in to comment.