Skip to content

Commit 82a9de6

Browse files
committed
remove partition view on asset events for non-sda assets
1 parent a1cbecc commit 82a9de6

File tree

3 files changed

+21
-125
lines changed

3 files changed

+21
-125
lines changed

Diff for: js_modules/dagster-ui/packages/ui-core/src/assets/AssetEvents.tsx

+13-86
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
import {
2-
Box,
3-
ButtonGroup,
4-
Colors,
5-
ErrorBoundary,
6-
NonIdealState,
7-
Spinner,
8-
Subheading,
9-
} from '@dagster-io/ui-components';
1+
import {Box, Colors, ErrorBoundary, NonIdealState, Spinner} from '@dagster-io/ui-components';
102
import * as React from 'react';
113
import {useMemo} from 'react';
124

135
import {AssetEventDetail, AssetEventDetailEmpty} from './AssetEventDetail';
146
import {AssetEventList} from './AssetEventList';
15-
import {AssetPartitionDetail, AssetPartitionDetailEmpty} from './AssetPartitionDetail';
167
import {CurrentRunsBanner} from './CurrentRunsBanner';
178
import {FailedRunSinceMaterializationBanner} from './FailedRunSinceMaterializationBanner';
189
import {LaunchAssetExecutionButton} from './LaunchAssetExecutionButton';
@@ -22,7 +13,6 @@ import {AssetViewDefinitionNodeFragment} from './types/AssetView.types';
2213
import {useAssetDefinition} from './useAssetDefinition';
2314
import {useAssetEventsFilters} from './useAssetEventsFilters';
2415
import {usePaginatedAssetEvents} from './usePaginatedAssetEvents';
25-
import {getXAxisForParams} from './useRecentAssetEvents';
2616
import {LiveDataForNode, stepKeyForAsset} from '../asset-graph/Utils';
2717
import {MaterializationHistoryEventTypeSelector, RepositorySelector} from '../graphql/types';
2818

@@ -50,18 +40,6 @@ export const AssetEvents = ({
5040
liveData,
5141
dataRefreshHint,
5242
}: Props) => {
53-
/**
54-
* We have a separate "Asset > Partitions" tab, but that is only available for SDAs with
55-
* pre-defined partitions. For non-SDAs, this Events page still displays a "Time | Partition"
56-
* picker and this xAxis can still be `partitions`!
57-
*
58-
* The partitions behavior in this case isn't ideal because the UI only "sees" partition names
59-
* in the events it has fetched. Users should upgrade to SDAs for a better experience.
60-
*
61-
* To test this easily, unload / break your code location so your SDA becomes a non-SDA :-)
62-
*/
63-
const xAxis = getXAxisForParams(params, {defaultToPartitions: false});
64-
6543
const {filterButton, activeFiltersJsx, filterState} = useAssetEventsFilters({
6644
assetKey,
6745
assetNode,
@@ -80,8 +58,10 @@ export const AssetEvents = ({
8058
return combinedParams;
8159
}, [params, filterState.dateRange]);
8260

83-
const {materializations, observations, loadedPartitionKeys, fetchMore, fetchLatest, loading} =
84-
usePaginatedAssetEvents(assetKey, combinedParams);
61+
const {materializations, observations, fetchMore, fetchLatest, loading} = usePaginatedAssetEvents(
62+
assetKey,
63+
params,
64+
);
8565

8666
React.useEffect(() => {
8767
fetchLatest();
@@ -92,21 +72,19 @@ export const AssetEvents = ({
9272
combinedParams.after,
9373
combinedParams.before,
9474
combinedParams.status,
95-
combinedParams.partitions,
9675
]);
9776

9877
const grouped = useGroupedEvents(
99-
xAxis,
78+
'time',
10079
filterState.type?.includes('Materialization') ? materializations : [],
10180
filterState.type?.includes('Observation') ? observations : [],
102-
loadedPartitionKeys,
81+
[],
10382
);
10483

10584
const onSetFocused = (group: AssetEventGroup | undefined) => {
106-
const updates: Partial<AssetViewParams> =
107-
xAxis === 'time'
108-
? {time: group?.timestamp !== params.time ? group?.timestamp || '' : ''}
109-
: {partition: group?.partition !== params.partition ? group?.partition || '' : ''};
85+
const updates: Partial<AssetViewParams> = {
86+
time: group?.timestamp !== params.time ? group?.timestamp || '' : '',
87+
};
11088
setParams({...params, ...updates});
11189
};
11290

@@ -119,16 +97,6 @@ export const AssetEvents = ({
11997
: false,
12098
) || grouped[0];
12199

122-
// Note: This page still has a LOT of logic for displaying events by partition but it's only enabled
123-
// in one case -- when the asset is an old-school, non-software-defined asset with partition keys
124-
// on it's materializations but no defined partition set.
125-
//
126-
const assetHasUndefinedPartitions =
127-
!assetNode?.partitionDefinition && grouped.some((g) => g.partition);
128-
const assetHasLineage = materializations.some(
129-
(m) => 'assetLineage' in m && m.assetLineage.length > 0,
130-
);
131-
132100
const onKeyDown = (e: React.KeyboardEvent<any>) => {
133101
const shift = {ArrowDown: 1, ArrowUp: -1}[e.key];
134102
if (!shift || !focused || e.isDefaultPrevented()) {
@@ -148,8 +116,7 @@ export const AssetEvents = ({
148116
const hasFilter =
149117
combinedParams.status !== MaterializationHistoryEventTypeSelector.ALL ||
150118
combinedParams.before !== undefined ||
151-
combinedParams.after !== undefined ||
152-
combinedParams.partitions !== undefined;
119+
combinedParams.after !== undefined;
153120
if (!loading && !materializations.length && !observations.length && !hasFilter) {
154121
return (
155122
<Box padding={{horizontal: 24, vertical: 64}}>
@@ -185,33 +152,6 @@ export const AssetEvents = ({
185152
{activeFiltersJsx}
186153
</Box>
187154
) : null}
188-
{assetHasUndefinedPartitions && (
189-
<Box
190-
flex={{justifyContent: 'space-between', alignItems: 'center'}}
191-
border="bottom"
192-
padding={{vertical: 16, horizontal: 24}}
193-
style={{marginBottom: -1}}
194-
>
195-
<Subheading>Asset Events</Subheading>
196-
<div style={{margin: '-6px 0 '}}>
197-
<ButtonGroup
198-
activeItems={new Set([xAxis])}
199-
buttons={[
200-
{id: 'partition', label: 'By partition'},
201-
{id: 'time', label: 'By timestamp'},
202-
]}
203-
onClick={(id: string) =>
204-
setParams(
205-
id === 'time'
206-
? {...params, partition: undefined, time: focused?.timestamp || ''}
207-
: {...params, partition: focused?.partition || '', time: undefined},
208-
)
209-
}
210-
/>
211-
</div>
212-
</Box>
213-
)}
214-
215155
{assetNode && !assetNode.partitionDefinition && (
216156
<>
217157
<FailedRunSinceMaterializationBanner
@@ -258,7 +198,7 @@ export const AssetEvents = ({
258198
</Box>
259199
) : (
260200
<AssetEventList
261-
xAxis={xAxis}
201+
xAxis="time"
262202
groups={grouped}
263203
focused={focused}
264204
setFocused={onSetFocused}
@@ -274,20 +214,7 @@ export const AssetEvents = ({
274214
border="left"
275215
>
276216
<ErrorBoundary region="event" resetErrorOnChange={[focused]}>
277-
{xAxis === 'partition' ? (
278-
focused ? (
279-
<AssetPartitionDetail
280-
group={focused}
281-
hasLineage={assetHasLineage}
282-
assetKey={assetKey}
283-
stepKey={assetNode ? stepKeyForAsset(assetNode) : undefined}
284-
latestRunForPartition={null}
285-
changedReasons={assetNode?.changedReasons}
286-
/>
287-
) : (
288-
<AssetPartitionDetailEmpty />
289-
)
290-
) : focused?.latest ? (
217+
{focused?.latest ? (
291218
<AssetEventDetail assetKey={assetKey} event={focused.latest} />
292219
) : (
293220
<AssetEventDetailEmpty />

Diff for: js_modules/dagster-ui/packages/ui-core/src/assets/usePaginatedAssetEvents.tsx

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import min from 'lodash/min';
2-
import uniq from 'lodash/uniq';
32
import uniqBy from 'lodash/uniqBy';
43
import React, {useCallback, useEffect, useMemo, useState} from 'react';
54

65
import {clipEventsToSharedMinimumTime} from './clipEventsToSharedMinimumTime';
76
import {AssetKey, AssetViewParams} from './types';
87
import {
9-
AssetEventsQuery,
10-
AssetEventsQueryVariables,
118
AssetObservationFragment,
9+
RecentAssetEventsQuery,
10+
RecentAssetEventsQueryVariables,
1211
} from './types/useRecentAssetEvents.types';
13-
import {ASSET_EVENTS_QUERY, AssetMaterializationFragment} from './useRecentAssetEvents';
12+
import {AssetMaterializationFragment, RECENT_ASSET_EVENTS_QUERY} from './useRecentAssetEvents';
1413
import {useApolloClient} from '../apollo-client';
1514
import {MaterializationHistoryEventTypeSelector} from '../graphql/types';
1615
import {useBlockTraceUntilTrue} from '../performance/TraceContext';
@@ -31,7 +30,6 @@ export function usePaginatedAssetEvents(
3130
params: Pick<AssetViewParams, 'asOf'> & {
3231
before?: number;
3332
after?: number;
34-
partitions?: string[];
3533
status?: MaterializationHistoryEventTypeSelector;
3634
},
3735
) {
@@ -53,23 +51,22 @@ export function usePaginatedAssetEvents(
5351
setObservations([]);
5452
setMaterializations([]);
5553
setCursor(undefined);
56-
}, [assetKey, params.before, params.after, params.partitions, params.status]);
54+
}, [assetKey, params.before, params.after, params.status]);
5755

5856
const fetch = useCallback(
5957
async (before = initialAsOf ?? beforeParam, cursor: string | undefined = undefined) => {
6058
if (!assetKey) {
6159
return;
6260
}
6361
setLoading(true);
64-
const {data} = await client.query<AssetEventsQuery, AssetEventsQueryVariables>({
65-
query: ASSET_EVENTS_QUERY,
62+
const {data} = await client.query<RecentAssetEventsQuery, RecentAssetEventsQueryVariables>({
63+
query: RECENT_ASSET_EVENTS_QUERY,
6664
variables: {
6765
assetKey: {path: assetKey.path},
6866
limit: 100,
6967
cursor,
7068
before,
7169
after: afterParam,
72-
partitions: params.partitions,
7370
eventTypeSelector: params.status ?? MaterializationHistoryEventTypeSelector.ALL,
7471
},
7572
});
@@ -92,23 +89,18 @@ export function usePaginatedAssetEvents(
9289
);
9390
setCursor(asset?.assetMaterializationHistory?.cursor);
9491
},
95-
[initialAsOf, beforeParam, assetKey, client, afterParam, params.partitions, params.status],
92+
[initialAsOf, beforeParam, assetKey, client, afterParam, params.status],
9693
);
9794

9895
useBlockTraceUntilTrue('AssetEventsQuery', loaded);
9996

10097
return useMemo(() => {
10198
const all = [...materializations, ...observations];
10299

103-
// Note: If we "discover" more partition keys of a non-SDA as more events are loaded, we want
104-
// those to be appended to the end so things don't jump around, so there is no sort() here.
105-
const loadedPartitionKeys = uniq(all.map((p) => p.partition!).filter(Boolean)).reverse();
106-
107100
return {
108101
loading,
109102
materializations,
110103
observations,
111-
loadedPartitionKeys,
112104
fetchLatest: fetch,
113105
fetchMore: () => fetch(`${min(all.map((e) => Number(e.timestamp)))}`, cursor),
114106
};

Diff for: js_modules/dagster-ui/packages/ui-core/src/assets/useRecentAssetEvents.tsx

+1-24
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {useMemo} from 'react';
22

33
import {ASSET_LINEAGE_FRAGMENT} from './AssetLineageElements';
4-
import {AssetKey, AssetViewParams} from './types';
4+
import {AssetKey} from './types';
55
import {gql, useQuery} from '../apollo-client';
66
import {clipEventsToSharedMinimumTime} from './clipEventsToSharedMinimumTime';
77
import {MaterializationHistoryEventTypeSelector} from '../graphql/types';
@@ -21,29 +21,6 @@ export type AssetMaterializationFragment =
2121
| AssetSuccessfulMaterializationFragment
2222
| AssetFailedToMaterializeFragment;
2323

24-
/**
25-
The params behavior on this page is a bit nuanced - there are two main query
26-
params: ?timestamp= and ?partition= and only one is set at a time. They can
27-
be undefined, an empty string or a value and all three states are used.
28-
- If both are undefined, we expand the first item in the table by default
29-
- If one is present, it determines which xAxis is used (partition grouping)
30-
- If one is present and set to a value, that item in the table is expanded.
31-
- If one is present but an empty string, no items in the table is expanded.
32-
*/
33-
export function getXAxisForParams(
34-
params: Pick<AssetViewParams, 'asOf' | 'partition' | 'time'>,
35-
{defaultToPartitions}: {defaultToPartitions: boolean},
36-
) {
37-
const xAxisDefault = defaultToPartitions ? 'partition' : 'time';
38-
const xAxis: 'partition' | 'time' =
39-
params.partition !== undefined
40-
? 'partition'
41-
: params.time !== undefined || params.asOf
42-
? 'time'
43-
: xAxisDefault;
44-
return xAxis;
45-
}
46-
4724
export function useLatestAssetPartitions(assetKey: AssetKey | undefined, limit: number) {
4825
const queryResult = useQuery<LatestAssetPartitionsQuery, LatestAssetPartitionsQueryVariables>(
4926
LATEST_ASSET_PARTITIONS_QUERY,

0 commit comments

Comments
 (0)