Skip to content

Commit

Permalink
Hook up run selection to GanttChart (#26254)
Browse files Browse the repository at this point in the history
## Summary & Motivation
Hook up the run selection syntax to `GanttChart.tsx` and add feature flag for run selection syntax.

## How I Tested These Changes
Existing tests should pass
  • Loading branch information
briantu authored Dec 4, 2024
1 parent 40796bd commit b395187
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 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
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
Expand Up @@ -6,7 +6,7 @@ import {StepKind} from '../graphql/types';
import {IStepMetadata, IStepState} from '../runs/RunMetadataProvider';

export type RunGraphQueryItem = GraphQueryItem & {
metadata: IStepMetadata | undefined;
metadata?: IStepMetadata;
};

/**
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);
};

1 comment on commit b395187

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-3b13650eg-elementl.vercel.app

Built with commit b395187.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.