Skip to content

Commit b148b99

Browse files
committed
[INTERNAL_BRANCH=status-selection-syntax]
1 parent 53dcc92 commit b148b99

File tree

52 files changed

+1204
-866
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1204
-866
lines changed

Diff for: js_modules/dagster-ui/packages/ui-core/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"generate-run-selection": "ts-node -O '{\"module\": \"commonjs\"}' ./src/scripts/generateRunSelection.ts && eslint src/run-selection/generated/ --fix -c .eslintrc.js",
2020
"generate-op-selection": "ts-node -O '{\"module\": \"commonjs\"}' ./src/scripts/generateOpSelection.ts && eslint src/op-selection/generated/ --fix -c .eslintrc.js",
2121
"storybook": "storybook dev -p 6006",
22-
"build-storybook": "storybook build"
22+
"build-storybook": "storybook build",
23+
"find-circular-dependencies": "ts-node -O '{\"module\": \"commonjs\"}' ./src/scripts/findCircularDependencies.ts"
2324
},
2425
"peerDependencies": {
2526
"@apollo/client": "3.9.11",

Diff for: js_modules/dagster-ui/packages/ui-core/src/app/UserSettingsDialog/UserSettingsDialog.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ const UserSettingsDialogContent = ({onClose, visibleFlags}: DialogContentProps)
176176
}}
177177
>
178178
<Box flex={{direction: 'row', gap: 4, alignItems: 'center'}}>
179-
Reset IndexedDB cache
179+
Reset IndexedDB cache (Close all other tabs first!)
180180
<Tooltip content="If you're seeing stale definitions or experiencing client side bugs then this may fix it">
181181
<Icon name="info" />
182182
</Tooltip>

Diff for: js_modules/dagster-ui/packages/ui-core/src/asset-graph/AssetGraphExplorer.tsx

+2-6
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,9 @@ import {
4242
import {assetKeyTokensInRange} from './assetKeyTokensInRange';
4343
import {AssetGraphLayout, GroupLayout} from './layout';
4444
import {AssetGraphExplorerSidebar} from './sidebar/Sidebar';
45+
import {AssetGraphQueryItem} from './types';
4546
import {AssetNodeForGraphQueryFragment} from './types/useAssetGraphData.types';
46-
import {
47-
AssetGraphFetchScope,
48-
AssetGraphQueryItem,
49-
useAssetGraphData,
50-
useFullAssetGraphData,
51-
} from './useAssetGraphData';
47+
import {AssetGraphFetchScope, useAssetGraphData, useFullAssetGraphData} from './useAssetGraphData';
5248
import {AssetLocation, useFindAssetLocation} from './useFindAssetLocation';
5349
import {AssetLiveDataRefreshButton} from '../asset-data/AssetLiveDataProvider';
5450
import {LaunchAssetExecutionButton} from '../assets/LaunchAssetExecutionButton';

Diff for: js_modules/dagster-ui/packages/ui-core/src/asset-graph/ComputeGraphData.types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import {AssetGraphQueryItem} from './types';
12
import {AssetKey} from '../assets/types';
23
import {AssetNodeForGraphQueryFragment} from './types/useAssetGraphData.types';
3-
import {AssetGraphFetchScope, AssetGraphQueryItem} from './useAssetGraphData';
4+
import {AssetGraphFetchScope} from './useAssetGraphData';
45

56
type BaseType = {
67
id: number;

Diff for: js_modules/dagster-ui/packages/ui-core/src/asset-graph/layout.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as dagre from 'dagre';
22

33
import {GraphData, GraphId, GraphNode, groupIdForNode, isGroupId} from './Utils';
4-
import {IBounds, IPoint} from '../graph/common';
4+
import type {IBounds, IPoint} from '../graph/common';
55
import {ChangeReason} from '../graphql/types';
66

77
export type AssetLayoutDirection = 'vertical' | 'horizontal';

Diff for: js_modules/dagster-ui/packages/ui-core/src/asset-graph/useAssetGraphData.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {GraphData, buildGraphData as buildGraphDataImpl, tokenForAssetKey} from
1010
import {gql} from '../apollo-client';
1111
import {computeGraphData as computeGraphDataImpl} from './ComputeGraphData';
1212
import {BuildGraphDataMessageType, ComputeGraphDataMessageType} from './ComputeGraphData.types';
13+
import {AssetGraphQueryItem, AssetNode} from './types';
1314
import {featureEnabled} from '../app/Flags';
1415
import {
1516
AssetGraphQuery,
@@ -47,10 +48,6 @@ export interface AssetGraphFetchScope {
4748
useWorker?: boolean;
4849
}
4950

50-
export type AssetGraphQueryItem = GraphQueryItem & {
51-
node: AssetNode;
52-
};
53-
5451
export function useFullAssetGraphData(
5552
options: Omit<AssetGraphFetchScope, 'groupSelector' | 'pipelineSelector'>,
5653
) {
@@ -194,7 +191,7 @@ export function useAssetGraphData(opsQuery: string, options: AssetGraphFetchScop
194191
const currentRequestRef = useRef(0);
195192

196193
const {loading: supplementaryDataLoading, data: supplementaryData} =
197-
useAssetGraphSupplementaryData(opsQuery);
194+
useAssetGraphSupplementaryData(opsQuery, allNodes);
198195

199196
const spawnComputeGraphDataWorker = useMemo(
200197
() => workerSpawner(() => new Worker(new URL('./ComputeGraphData.worker', import.meta.url))),
@@ -274,8 +271,6 @@ export function useAssetGraphData(opsQuery: string, options: AssetGraphFetchScop
274271
};
275272
}
276273

277-
type AssetNode = AssetNodeForGraphQueryFragment;
278-
279274
const computeGraphData = indexedDBAsyncMemoize<GraphDataState, typeof computeGraphDataWrapper>(
280275
computeGraphDataWrapper,
281276
(props) => {
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,46 @@
1-
import {AssetKey} from '../assets/types';
1+
import {useMemo} from 'react';
22

3-
export type SupplementaryInformation = Record<string, AssetKey[]> | null | undefined;
3+
import {useAssetsHealthData} from '../asset-data/AssetHealthDataProvider';
4+
import {parseExpression} from '../asset-selection/AssetSelectionSupplementaryDataVisitor';
5+
import {getSupplementaryDataKey} from '../asset-selection/util';
6+
import {AssetKey} from '../assets/types';
7+
import {AssetNodeForGraphQueryFragment} from './types/useAssetGraphData.types';
8+
import {SupplementaryInformation} from '../asset-selection/types';
49

5-
// Stub for cloud to supply extended selection syntax filtering capabilities
10+
const emptyObject = {} as SupplementaryInformation;
611
export const useAssetGraphSupplementaryData = (
7-
_: string,
8-
): {loading: boolean; data: SupplementaryInformation | null} => {
12+
selection: string,
13+
nodes: AssetNodeForGraphQueryFragment[],
14+
): {loading: boolean; data: SupplementaryInformation} => {
15+
const {liveDataByNode} = useAssetsHealthData(
16+
useMemo(() => nodes.map((node) => node.assetKey), [nodes]),
17+
);
18+
19+
const loading = Object.keys(liveDataByNode).length !== nodes.length;
20+
21+
const assetsByStatus = useMemo(() => {
22+
return Object.values(liveDataByNode).reduce(
23+
(acc, liveData) => {
24+
const status = liveData.assetHealth?.assetHealth ?? 'UNKNOWN';
25+
const supplementaryDataKey = getSupplementaryDataKey({
26+
field: 'status',
27+
value: status,
28+
});
29+
acc[supplementaryDataKey] = acc[supplementaryDataKey] || [];
30+
acc[supplementaryDataKey].push(liveData.assetKey);
31+
return acc;
32+
},
33+
{} as Record<string, AssetKey[]>,
34+
);
35+
}, [liveDataByNode]);
36+
37+
const needsAssetHealthData = useMemo(() => {
38+
const filters = parseExpression(selection);
39+
return filters.some((filter) => filter.field === 'status');
40+
}, [selection]);
41+
942
return {
10-
loading: false,
11-
data: null,
43+
loading: needsAssetHealthData && loading,
44+
data: loading ? emptyObject : assetsByStatus,
1245
};
1346
};

Diff for: js_modules/dagster-ui/packages/ui-core/src/asset-selection/AntlrAssetSelectionVisitor.oss.ts

+36-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import {AbstractParseTreeVisitor} from 'antlr4ts/tree/AbstractParseTreeVisitor';
22
import escapeRegExp from 'lodash/escapeRegExp';
3-
import {SupplementaryInformation} from 'shared/asset-graph/useAssetGraphSupplementaryData.oss';
43

5-
import {getFunctionName, getTraversalDepth, getValue} from './util';
4+
import {SupplementaryInformation} from './types';
5+
import {
6+
getAssetsByKey,
7+
getFunctionName,
8+
getSupplementaryDataKey,
9+
getTraversalDepth,
10+
getValue,
11+
} from './util';
612
import {GraphTraverser} from '../app/GraphQueryImpl';
7-
import {AssetGraphQueryItem} from '../asset-graph/useAssetGraphData';
13+
import {tokenForAssetKey} from '../asset-graph/Utils';
14+
import {AssetGraphQueryItem} from '../asset-graph/types';
815
import {buildRepoPathForHuman} from '../workspace/buildRepoAddress';
916
import {
1017
AllExpressionContext,
@@ -21,6 +28,7 @@ import {
2128
OwnerAttributeExprContext,
2229
ParenthesizedExpressionContext,
2330
StartContext,
31+
StatusAttributeExprContext,
2432
TagAttributeExprContext,
2533
TraversalAllowedExpressionContext,
2634
UpAndDownTraversalExpressionContext,
@@ -32,20 +40,24 @@ export class AntlrAssetSelectionVisitor
3240
extends AbstractParseTreeVisitor<Set<AssetGraphQueryItem>>
3341
implements AssetSelectionVisitor<Set<AssetGraphQueryItem>>
3442
{
35-
all_assets: Set<AssetGraphQueryItem>;
36-
focus_assets: Set<AssetGraphQueryItem>;
37-
traverser: GraphTraverser<AssetGraphQueryItem>;
43+
protected all_assets: Set<AssetGraphQueryItem>;
44+
public focus_assets: Set<AssetGraphQueryItem>;
45+
protected traverser: GraphTraverser<AssetGraphQueryItem>;
46+
protected supplementaryData: SupplementaryInformation;
47+
protected allAssetsByKey: Map<string, AssetGraphQueryItem>;
3848

3949
protected defaultResult() {
4050
return new Set<AssetGraphQueryItem>();
4151
}
4252

4353
// Supplementary data is not used in oss
44-
constructor(all_assets: AssetGraphQueryItem[], _supplementaryData?: SupplementaryInformation) {
54+
constructor(all_assets: AssetGraphQueryItem[], supplementaryData: SupplementaryInformation) {
4555
super();
4656
this.all_assets = new Set(all_assets);
4757
this.focus_assets = new Set();
4858
this.traverser = new GraphTraverser(all_assets);
59+
this.supplementaryData = supplementaryData;
60+
this.allAssetsByKey = getAssetsByKey(all_assets);
4961
}
5062

5163
visitStart(ctx: StartContext) {
@@ -208,4 +220,21 @@ export class AntlrAssetSelectionVisitor
208220
}
209221
return selection;
210222
}
223+
224+
visitStatusAttributeExpr(ctx: StatusAttributeExprContext) {
225+
const statusName: string = getValue(ctx.value());
226+
const supplementaryDataKey = getSupplementaryDataKey({
227+
field: 'status',
228+
value: statusName,
229+
});
230+
const matchingAssetKeys = this.supplementaryData?.[supplementaryDataKey];
231+
if (!matchingAssetKeys) {
232+
return new Set<AssetGraphQueryItem>();
233+
}
234+
return new Set(
235+
matchingAssetKeys
236+
.map((key) => this.allAssetsByKey.get(tokenForAssetKey(key))!)
237+
.filter(Boolean),
238+
);
239+
}
211240
}

Diff for: js_modules/dagster-ui/packages/ui-core/src/asset-selection/__tests__/AntlrAssetSelection.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable jest/expect-expect */
2-
import {AssetGraphQueryItem} from '../../asset-graph/useAssetGraphData';
2+
import {AssetGraphQueryItem} from '../../asset-graph/types';
33
import {
44
buildAssetNode,
55
buildDefinitionTag,

Diff for: js_modules/dagster-ui/packages/ui-core/src/asset-selection/filterAssetSelectionByQuery.oss.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {FeatureFlag} from 'shared/app/FeatureFlags.oss';
2-
import {SupplementaryInformation} from 'shared/asset-graph/useAssetGraphSupplementaryData.oss';
32

43
import {AssetSelectionQueryResult, parseAssetSelectionQuery} from './parseAssetSelectionQuery';
4+
import {SupplementaryInformation} from './types';
55
import {featureEnabled} from '../app/Flags';
66
import {filterByQuery} from '../app/GraphQueryImpl';
7-
import {AssetGraphQueryItem} from '../asset-graph/useAssetGraphData';
7+
import {AssetGraphQueryItem} from '../asset-graph/types';
88
import {weakMapMemoize} from '../util/weakMapMemoize';
99

1010
export const filterAssetSelectionByQuery = weakMapMemoize(

Diff for: js_modules/dagster-ui/packages/ui-core/src/asset-selection/generated/AssetSelection.interp

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: js_modules/dagster-ui/packages/ui-core/src/asset-selection/generated/AssetSelection.tokens

+18-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)