Skip to content

Commit

Permalink
Hook up op selection syntax to frontend (#26488)
Browse files Browse the repository at this point in the history
## Summary & Motivation
We want to hook up the new op selection syntax so that it is being used
on the frontend.
  • Loading branch information
briantu authored Dec 19, 2024
1 parent 452d713 commit cda92cd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum FeatureFlag {
flagAssetSelectionSyntax = 'flagAssetSelectionSyntax',
flagRunSelectionSyntax = 'flagRunSelectionSyntax',
flagAssetSelectionWorker = 'flagAssetSelectionWorker',
flagOpSelectionSyntax = 'flagOpSelectionSyntax',

// Flags for tests
__TestFlagDefaultNone = '__TestFlagDefaultNone',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {OpSelectorQuery, OpSelectorQueryVariables} from './types/OpSelector.type
import {filterByQuery} from '../app/GraphQueryImpl';
import {PYTHON_ERROR_FRAGMENT} from '../app/PythonErrorFragment';
import {ShortcutHandler} from '../app/ShortcutHandler';
import {filterOpSelectionByQuery} from '../op-selection/AntlrOpSelection';
import {explodeCompositesInHandleGraph} from '../pipelines/CompositeSupport';
import {GRAPH_EXPLORER_SOLID_HANDLE_FRAGMENT} from '../pipelines/GraphExplorer';
import {GraphQueryInput} from '../ui/GraphQueryInput';
Expand Down Expand Up @@ -85,7 +86,7 @@ export const OpSelector = (props: IOpSelectorProps) => {
const opsFetchError =
(data?.pipelineOrError.__typename !== 'Pipeline' && data?.pipelineOrError.message) || null;

const queryResultOps = filterByQuery(ops, query).all;
const queryResultOps = filterOpSelectionByQuery(ops, query).all;
const invalidOpSelection = !loading && queryResultOps.length === 0;

const errorMessage = invalidOpSelection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {CharStreams, CommonTokenStream} from 'antlr4ts';
import {FeatureFlag} from 'shared/app/FeatureFlags.oss';

import {AntlrOpSelectionVisitor} from './AntlrOpSelectionVisitor';
import {GraphQueryItem} from '../app/GraphQueryImpl';
import {GraphQueryItem, filterByQuery} from '../app/GraphQueryImpl';
import {AntlrInputErrorListener} from '../asset-selection/AntlrAssetSelection';
import {OpSelectionLexer} from './generated/OpSelectionLexer';
import {OpSelectionParser} from './generated/OpSelectionParser';
import {featureEnabled} from '../app/Flags';

type OpSelectionQueryResult = {
all: GraphQueryItem[];
Expand Down Expand Up @@ -40,3 +42,18 @@ export const parseOpSelectionQuery = (
return e as Error;
}
};

export const filterOpSelectionByQuery = (
all_ops: GraphQueryItem[],
query: string,
): OpSelectionQueryResult => {
if (featureEnabled(FeatureFlag.flagOpSelectionSyntax)) {
const result = parseOpSelectionQuery(all_ops, query);
if (result instanceof Error) {
// fall back to old behavior
return filterByQuery(all_ops, query);
}
return result;
}
return filterByQuery(all_ops, query);
};

1 comment on commit cda92cd

@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-kvjksjbku-elementl.vercel.app

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

Please sign in to comment.