Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook up op selection syntax to frontend #26488

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
};
Loading