Skip to content

Commit

Permalink
Hook up run selection to GanttChart
Browse files Browse the repository at this point in the history
  • Loading branch information
briantu committed Dec 3, 2024
1 parent 0d8068c commit 00ae076
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export enum FeatureFlag {
flagDisableAutoLoadDefaults = 'flagDisableAutoLoadDefaults',
flagLegacyRunsPage = 'flagLegacyRunsPage',
flagAssetSelectionSyntax = 'flagAssetSelectionSyntax',
flagRunSelectionSyntax = 'flagRunSelectionSyntax',

// Flags for tests
__TestFlagDefaultNone = '__TestFlagDefaultNone',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ import {GanttChartTimescale} from './GanttChartTimescale';
import {GanttStatusPanel} from './GanttStatusPanel';
import {OptionsContainer, OptionsSpacer} from './VizComponents';
import {ZoomSlider} from './ZoomSlider';
import {RunGraphQueryItem} from './toGraphQueryItems';
import {useGanttChartMode} from './useGanttChartMode';
import {AppContext} from '../app/AppContext';
import {GraphQueryItem, filterByQuery} from '../app/GraphQueryImpl';
import {GraphQueryItem} from '../app/GraphQueryImpl';
import {withMiddleTruncation} from '../app/Util';
import {WebSocketContext} from '../app/WebSocketProvider';
import {useThrottledMemo} from '../hooks/useThrottledMemo';
import {filterRunSelectionByQuery} from '../run-selection/AntlrRunSelection';
import {CancelRunButton} from '../runs/RunActionButtons';
import {
EMPTY_RUN_METADATA,
Expand Down Expand Up @@ -94,7 +96,7 @@ interface GanttChartProps {
selection: StepSelection;
focusedTime: number | null;
runId: string;
graph: GraphQueryItem[];
graph: RunGraphQueryItem[];
options?: Partial<GanttChartLayoutOptions>;
metadata?: IRunMetadataDict;
toolbarActions?: React.ReactChild;
Expand All @@ -121,7 +123,7 @@ export const GanttChart = (props: GanttChartProps) => {

const cachedLayout = React.useRef<GanttChartLayout | null>(null);
const cachedLayoutParams = React.useRef<BuildLayoutParams | null>(null);
const graphFiltered = filterByQuery(graph, selection.query);
const graphFiltered = filterRunSelectionByQuery(graph, selection.query);
const layoutParams = React.useMemo(
() => ({
nodes: state.hideUnselectedSteps ? graphFiltered.all : graph,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {RunMetadataProviderMessageFragment} from '../../runs/types/RunMetadataProvider.types';
import {IGanttNode} from '../Constants';
import {RunGraphQueryItem} from '../toGraphQueryItems';

export const GRAPH: IGanttNode[] = [
export const GRAPH: RunGraphQueryItem[] = [
{
name: 'load_pieces',
inputs: [],
Expand All @@ -16,31 +16,37 @@ export const GRAPH: IGanttNode[] = [
],
},
],
metadata: undefined,
},
{
name: 'compute_piece[1_XASD_plus_8]',
inputs: [{dependsOn: [{solid: {name: 'load_pieces'}}]}],
outputs: [{dependedBy: [{solid: {name: 'merge_and_analyze'}}]}],
metadata: undefined,
},
{
name: 'compute_piece[2_XASD_plus_8]',
inputs: [{dependsOn: [{solid: {name: 'load_pieces'}}]}],
outputs: [{dependedBy: [{solid: {name: 'merge_and_analyze'}}]}],
metadata: undefined,
},
{
name: 'compute_piece[3_XASD_plus_8]',
inputs: [{dependsOn: [{solid: {name: 'load_pieces'}}]}],
outputs: [{dependedBy: [{solid: {name: 'merge_and_analyze'}}]}],
metadata: undefined,
},
{
name: 'compute_piece[4_XASD_plus_8]',
inputs: [{dependsOn: [{solid: {name: 'load_pieces'}}]}],
outputs: [{dependedBy: [{solid: {name: 'merge_and_analyze'}}]}],
metadata: undefined,
},
{
name: 'compute_piece[?]',
inputs: [{dependsOn: [{solid: {name: 'load_pieces'}}]}],
outputs: [{dependedBy: [{solid: {name: 'merge_and_analyze'}}]}],
metadata: undefined,
},
{
name: 'merge_and_analyze',
Expand All @@ -56,6 +62,7 @@ export const GRAPH: IGanttNode[] = [
},
],
outputs: [],
metadata: undefined,
},
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {RunMetadataProviderMessageFragment} from '../../runs/types/RunMetadataProvider.types';
import {IGanttNode} from '../Constants';
import {RunGraphQueryItem} from '../toGraphQueryItems';

export const GRAPH: IGanttNode[] = [
{name: 'aop', inputs: [], outputs: [{dependedBy: [{solid: {name: 'bop'}}]}]},
{name: 'cop', inputs: [{dependsOn: [{solid: {name: 'bop'}}]}], outputs: []},
export const GRAPH: RunGraphQueryItem[] = [
{name: 'aop', inputs: [], outputs: [{dependedBy: [{solid: {name: 'bop'}}]}], metadata: undefined},
{name: 'cop', inputs: [{dependsOn: [{solid: {name: 'bop'}}]}], outputs: [], metadata: undefined},
{
name: 'bop',
inputs: [{dependsOn: [{solid: {name: 'aop'}}]}],
outputs: [{dependedBy: [{solid: {name: 'cop'}}]}],
metadata: undefined,
},
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
import {RunMetadataProviderMessageFragment} from '../../runs/types/RunMetadataProvider.types';
import {IGanttNode} from '../Constants';
import {RunGraphQueryItem} from '../toGraphQueryItems';

export const GRAPH: IGanttNode[] = [
{name: 'A', inputs: [], outputs: [{dependedBy: [{solid: {name: 'B_very_long_step_name'}}]}]},
export const GRAPH: RunGraphQueryItem[] = [
{
name: 'A',
inputs: [],
outputs: [{dependedBy: [{solid: {name: 'B_very_long_step_name'}}]}],
metadata: undefined,
},
{
name: 'B_very_long_step_name',
inputs: [{dependsOn: [{solid: {name: 'A'}}]}],
outputs: [{dependedBy: [{solid: {name: 'C'}}, {solid: {name: 'D'}}]}],
metadata: undefined,
},
{
name: 'C',
inputs: [{dependsOn: [{solid: {name: 'B_very_long_step_name'}}]}],
outputs: [{dependedBy: [{solid: {name: 'E'}}]}],
metadata: undefined,
},
{
name: 'D',
inputs: [{dependsOn: [{solid: {name: 'B_very_long_step_name'}}]}],
outputs: [{dependedBy: [{solid: {name: 'E'}}]}],
metadata: undefined,
},
{
name: 'E',
inputs: [{dependsOn: [{solid: {name: 'C'}}, {solid: {name: 'D'}}]}],
outputs: [],
metadata: undefined,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {Box, Button, CustomTooltipProvider} from '@dagster-io/ui-components';
import {Meta} from '@storybook/react';
import {useState} from 'react';

import {GraphQueryItem} from '../../app/GraphQueryImpl';
import {RunStatus, buildRun, buildRunGroup, buildRunStatsSnapshot} from '../../graphql/types';
import {extractMetadataFromLogs} from '../../runs/RunMetadataProvider';
import {RunMetadataProviderMessageFragment} from '../../runs/types/RunMetadataProvider.types';
Expand All @@ -13,6 +12,7 @@ import {RUN_GROUP_PANEL_QUERY} from '../RunGroupPanel';
import * as Dynamic from '../__fixtures__/dynamic';
import * as Retry from '../__fixtures__/retry';
import * as Simple from '../__fixtures__/simple';
import {RunGraphQueryItem} from '../toGraphQueryItems';
import {RunGroupPanelQuery, RunGroupPanelQueryVariables} from '../types/RunGroupPanel.types';

const R1_START = 1619468000;
Expand Down Expand Up @@ -72,7 +72,7 @@ const GanttTestCase = ({
logs,
focusedTime,
}: {
graph: GraphQueryItem[];
graph: RunGraphQueryItem[];
logs: RunMetadataProviderMessageFragment[];
focusedTime: number;
}) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import {CharStreams, CommonTokenStream} from 'antlr4ts';
import {FeatureFlag} from 'shared/app/FeatureFlags.oss';

import {AntlrRunSelectionVisitor} from './AntlrRunSelectionVisitor';
import {AntlrInputErrorListener} from '../asset-selection/AntlrAssetSelection';
import {RunGraphQueryItem} from '../gantt/toGraphQueryItems';
import {RunSelectionLexer} from './generated/RunSelectionLexer';
import {RunSelectionParser} from './generated/RunSelectionParser';
import {featureEnabled} from '../app/Flags';
import {filterByQuery} from '../app/GraphQueryImpl';

type RunSelectionQueryResult = {
all: RunGraphQueryItem[];
Expand Down Expand Up @@ -40,3 +43,18 @@ export const parseRunSelectionQuery = (
return e as Error;
}
};

export const filterRunSelectionByQuery = (
all_runs: RunGraphQueryItem[],
query: string,
): RunSelectionQueryResult => {
if (featureEnabled(FeatureFlag.flagRunSelectionSyntax)) {
const result = parseRunSelectionQuery(all_runs, query);
if (result instanceof Error) {
// fall back to old behavior
return filterByQuery(all_runs, query);
}
return result;
}
return filterByQuery(all_runs, query);
};

0 comments on commit 00ae076

Please sign in to comment.