Skip to content

Commit

Permalink
Handle backfills
Browse files Browse the repository at this point in the history
  • Loading branch information
hellendag committed Jan 10, 2025
1 parent b12ff7d commit e1a95d6
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {AutomaterializeRunsTable} from './AutomaterializeRunsTable';
import {PartitionSubsetList} from './PartitionSubsetList';
import {PartitionTagSelector} from './PartitionTagSelector';
import {PolicyEvaluationTable} from './PolicyEvaluationTable';
import {runTableFiltersForEvaluation} from './runTableFiltersForEvaluation';
import {
AssetConditionEvaluationRecordFragment,
GetEvaluationsSpecificPartitionQuery,
Expand All @@ -22,7 +23,6 @@ import {usePartitionsForAssetKey} from './usePartitionsForAssetKey';
import {useFeatureFlags} from '../../app/Flags';
import {formatElapsedTimeWithMsec} from '../../app/Util';
import {Timestamp} from '../../app/time/Timestamp';
import {RunsFilter} from '../../graphql/types';
import {RunsFeedTableWithFilters} from '../../runs/RunsFeedTable';
import {AssetViewDefinitionNodeFragment} from '../types/AssetView.types';

Expand Down Expand Up @@ -111,21 +111,8 @@ export const AutomaterializeMiddlePanelWithData = ({

const {partitions: allPartitions} = usePartitionsForAssetKey(definition?.assetKey.path || []);

// For a single asset for a single tick, DA will either request a list of runs or a single backfill.
// When DA requests a backfill we want to show a row for that backfill in the table, so we need to
// construct the RunsFilter differently. Backfill IDs are 8 characters long, so we can use that to
// determine if a backfill was requested. If DA is updated to request multiple backfills in a
// single evaluation, or emit a combination of runs and backfills in a single evaluation, this
// logic will need to be updated.
const backfillIdLength = 8;
const runsFilter: RunsFilter | null = useMemo(
() =>
selectedEvaluation?.runIds.length
? selectedEvaluation.runIds.length === 1 &&
selectedEvaluation.runIds[0]?.length === backfillIdLength
? {tags: [{key: 'dagster/backfill', value: selectedEvaluation.runIds[0]}]}
: {runIds: selectedEvaluation.runIds}
: null,
const runsFilter = useMemo(
() => runTableFiltersForEvaluation(selectedEvaluation?.runIds || []),
[selectedEvaluation],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {ReactNode, useMemo, useState} from 'react';
import {GET_SLIM_EVALUATIONS_QUERY} from './GetEvaluationsQuery';
import {PartitionTagSelector} from './PartitionTagSelector';
import {QueryfulEvaluationDetailTable} from './QueryfulEvaluationDetailTable';
import {runTableFiltersForEvaluation} from './runTableFiltersForEvaluation';
import {
GetSlimEvaluationsQuery,
GetSlimEvaluationsQueryVariables,
Expand Down Expand Up @@ -174,6 +175,34 @@ const EvaluationDetailDialogContents = ({

const {runIds} = evaluation;

const body = () => {
if (tabId === 'evaluation') {
return (
<QueryfulEvaluationDetailTable
evaluation={evaluation}
assetKeyPath={assetKeyPath}
selectedPartition={selectedPartition}
setSelectedPartition={setSelectedPartition}
/>
);
}

const filter = runTableFiltersForEvaluation(evaluation.runIds);
if (filter) {
return <RunsFeedTableWithFilters filter={filter} includeRunsFromBackfills={false} />;
}

return (
<Box padding={{top: 64}} flex={{direction: 'row', justifyContent: 'center'}}>
<NonIdealState
icon="run"
title="No runs launched"
description="No runs were launched by this evaluation."
/>
</Box>
);
};

return (
<DialogContents
onTabChange={setTabId}
Expand All @@ -198,21 +227,7 @@ const EvaluationDetailDialogContents = ({
) : null}
</>
}
body={
tabId === 'evaluation' ? (
<QueryfulEvaluationDetailTable
evaluation={evaluation}
assetKeyPath={assetKeyPath}
selectedPartition={selectedPartition}
setSelectedPartition={setSelectedPartition}
/>
) : (
<RunsFeedTableWithFilters
filter={{runIds: evaluation.runIds}}
includeRunsFromBackfills={true}
/>
)
}
body={body()}
viewAllButton={
viewAllPath ? (
<AnchorButton to={viewAllPath} icon={<Icon name="automation_condition" />}>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {RunsFilter} from '../../graphql/types';

const BACKFILL_ID_LENGTH = 8;

/**
* For a single asset for a single tick, DA will either request a list of runs or a single backfill.
* When DA requests a backfill we want to show a row for that backfill in the table, so we need to
* construct the RunsFilter differently. Backfill IDs are 8 characters long, so we can use that to
* determine if a backfill was requested. If DA is updated to request multiple backfills in a
* single evaluation, or emit a combination of runs and backfills in a single evaluation, this
* logic will need to be updated.
*/
export const runTableFiltersForEvaluation = (runIds: string[]): RunsFilter | null => {
const firstRunId = runIds[0];
if (firstRunId) {
if (firstRunId.length === BACKFILL_ID_LENGTH) {
return {tags: [{key: 'dagster/backfill', value: firstRunId}]};
}
return {runIds};
}
return null;
};

0 comments on commit e1a95d6

Please sign in to comment.