Skip to content

Commit

Permalink
show the partition if present for disambiguation
Browse files Browse the repository at this point in the history
  • Loading branch information
bengotow committed Mar 4, 2025
1 parent 33a0d0f commit 7fc0031
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
2 changes: 1 addition & 1 deletion js_modules/dagster-ui/packages/ui-core/client.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// eslint-disable-next-line no-restricted-imports
import {Box, Caption, Colors, Tag} from '@dagster-io/ui-components';
import React from 'react';
import {Link} from 'react-router-dom';

import {MaterializationTag} from './MaterializationTag';
import {Timestamp} from '../app/time/Timestamp';
Expand All @@ -18,9 +19,11 @@ import {AssetViewDefinitionNodeFragment} from './types/AssetView.types';
export const SimpleStakeholderAssetStatus = ({
liveData,
assetNode,
partition,
}: {
liveData: LiveDataForNode | undefined;
assetNode: Pick<AssetViewDefinitionNodeFragment, 'assetKey' | 'isObservable'>;
partition: string | null;
}) => {
if (!liveData) {
return <span />;
Expand Down Expand Up @@ -53,20 +56,34 @@ export const SimpleStakeholderAssetStatus = ({
</Tag>
);
}
const partitionTag = partition ? (
<Tag intent="none">
<Link to={`?view=partitions&partition=${encodeURIComponent(partition)}`}>
<Caption color={Colors.textDefault()}>{partition}</Caption>
</Link>
</Tag>
) : undefined;

if (liveData.lastMaterialization) {
return (
<MaterializationTag
assetKey={assetNode.assetKey}
event={liveData.lastMaterialization}
stepKey={liveData.stepKey}
/>
<Box flex={{gap: 4}}>
<MaterializationTag
assetKey={assetNode.assetKey}
event={liveData.lastMaterialization}
stepKey={liveData.stepKey}
/>
{partitionTag}
</Box>
);
}
if (liveData.lastObservation && assetNode.isObservable) {
return (
<Tag intent="none">
<Timestamp timestamp={{ms: Number(liveData.lastObservation.timestamp)}} />
</Tag>
<Box flex={{gap: 4}}>
<Tag intent="none">
<Timestamp timestamp={{ms: Number(liveData.lastObservation.timestamp)}} />
</Tag>
{partitionTag}
</Box>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ export const AssetNodeOverview = ({
(entry) => isCanonicalRowCountMetadataEntry(entry),
) as IntMetadataEntry | undefined;

// The live data does not include a partition, but the timestamp on the live data triggers
// an update of `observation` and `materialization`, so they should be in sync. To make sure
// we never display incorrect data we verify that the timestamps match.
const liveDataPartition = assetNode?.isObservable
? partitionIfMatching(liveData?.lastObservation, observation)
: partitionIfMatching(liveData?.lastMaterialization, materialization);

const renderStatusSection = () => (
<Box flex={{direction: 'column', gap: 16}}>
<Box style={{display: 'grid', gridTemplateColumns: 'repeat(3, minmax(0, 1fr))'}}>
Expand All @@ -113,6 +120,7 @@ export const AssetNodeOverview = ({
{liveData ? (
<SimpleStakeholderAssetStatus
liveData={liveData}
partition={liveDataPartition}
assetNode={assetNode ?? cachedAssetNode!}
/>
) : (
Expand Down Expand Up @@ -361,3 +369,12 @@ export const AssetNodeOverviewLoading = () => (
}
/>
);
function partitionIfMatching(
liveDataEvent: {timestamp: string} | null | undefined,
event: {timestamp: string; partition: string | null} | undefined,
) {
if (!liveDataEvent || !event) {
return null;
}
return liveDataEvent.timestamp === event.timestamp ? event.partition : null;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ export const ASSET_OVERVIEW_METADATA_EVENTS_QUERY = gql`
assetMaterializations(limit: 1) {
timestamp
runId
partition
metadataEntries {
...MetadataEntryFragment
}
}
assetObservations(limit: 1) {
timestamp
runId
partition
metadataEntries {
...MetadataEntryFragment
}
Expand Down

0 comments on commit 7fc0031

Please sign in to comment.