From c5c74226d6e90363b97e02dff7ab70da73022f04 Mon Sep 17 00:00:00 2001 From: prha <1040172+prha@users.noreply.github.com> Date: Mon, 14 Nov 2022 08:57:01 -0800 Subject: [PATCH] incorporate run step history into step matrix (#10478) * incorporate run step history into step matrix * further cleanup --- .../core/src/partitions/PartitionStatus.tsx | 2 + .../src/partitions/PartitionStepStatus.tsx | 7 ++- .../core/src/partitions/RunMatrixUtils.tsx | 60 +++---------------- .../core/src/partitions/useMatrixData.tsx | 50 +++++++++------- 4 files changed, 41 insertions(+), 78 deletions(-) diff --git a/js_modules/dagit/packages/core/src/partitions/PartitionStatus.tsx b/js_modules/dagit/packages/core/src/partitions/PartitionStatus.tsx index bade78454dc1..319be6fd3d9b 100644 --- a/js_modules/dagit/packages/core/src/partitions/PartitionStatus.tsx +++ b/js_modules/dagit/packages/core/src/partitions/PartitionStatus.tsx @@ -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', } diff --git a/js_modules/dagit/packages/core/src/partitions/PartitionStepStatus.tsx b/js_modules/dagit/packages/core/src/partitions/PartitionStepStatus.tsx index f9d4759ac751..9581edd53d50 100644 --- a/js_modules/dagit/packages/core/src/partitions/PartitionStepStatus.tsx +++ b/js_modules/dagit/packages/core/src/partitions/PartitionStepStatus.tsx @@ -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'; @@ -45,7 +46,6 @@ import { PARTITION_MATRIX_SOLID_HANDLE_FRAGMENT, MatrixStep, PartitionRuns, - StatusSquareFinalColor, useMatrixData, MatrixData, } from './useMatrixData'; @@ -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 = ( diff --git a/js_modules/dagit/packages/core/src/partitions/RunMatrixUtils.tsx b/js_modules/dagit/packages/core/src/partitions/RunMatrixUtils.tsx index f1f0e8715e82..2cb13e313e0f 100644 --- a/js_modules/dagit/packages/core/src/partitions/RunMatrixUtils.tsx +++ b/js_modules/dagit/packages/core/src/partitions/RunMatrixUtils.tsx @@ -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', }; @@ -123,54 +125,24 @@ 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 { @@ -178,24 +150,6 @@ export const GridColumn = styled.div<{ 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% - ); - } - } } `; diff --git a/js_modules/dagit/packages/core/src/partitions/useMatrixData.tsx b/js_modules/dagit/packages/core/src/partitions/useMatrixData.tsx index 57667dff391b..b9b39ee10f46 100644 --- a/js_modules/dagit/packages/core/src/partitions/useMatrixData.tsx +++ b/js_modules/dagit/packages/core/src/partitions/useMatrixData.tsx @@ -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; @@ -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; } @@ -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 {