Skip to content

Commit

Permalink
replace GrapheneAssetNode isSource with isMaterializable
Browse files Browse the repository at this point in the history
  • Loading branch information
sryza committed Aug 5, 2024
1 parent 1878a2f commit 3d10a43
Show file tree
Hide file tree
Showing 31 changed files with 83 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ interface Props {

export const AssetNode = React.memo(
({definition, selected, computeKindTagsFilter, storageKindTagsFilter}: Props) => {
const isSource = definition.isSource;

const {liveData} = useAssetLiveData(definition.assetKey);
const storageKindTag = definition.tags?.find(isCanonicalStorageKindTag);
return (
Expand All @@ -53,7 +51,7 @@ export const AssetNode = React.memo(
/>
</Box>
<AssetNodeContainer $selected={selected}>
<AssetNodeBox $selected={selected} $isSource={isSource}>
<AssetNodeBox $selected={selected} $isMaterializable={definition.isMaterializable}>
<AssetNameRow definition={definition} />
<Box style={{padding: '6px 8px'}} flex={{direction: 'column', gap: 4}} border="top">
{definition.description ? (
Expand All @@ -63,7 +61,7 @@ export const AssetNode = React.memo(
) : (
<AssetDescription $color={Colors.textLight()}>No description</AssetDescription>
)}
{definition.isPartitioned && !definition.isSource && (
{definition.isPartitioned && definition.isMaterializable && (
<PartitionCountTags definition={definition} liveData={liveData} />
)}
</Box>
Expand Down Expand Up @@ -98,13 +96,13 @@ export const AssetNameRow = ({definition}: {definition: AssetNodeFragment}) => {
const displayName = definition.assetKey.path[definition.assetKey.path.length - 1]!;

return (
<AssetName $isSource={definition.isSource}>
<AssetName $isMaterializable={definition.isMaterializable}>
<span style={{marginTop: 1}}>
<Icon name={definition.isSource ? 'source_asset' : 'asset'} />
<Icon name={definition.isMaterializable ? 'asset' : 'source_asset'} />
</span>
<div
data-tooltip={displayName}
data-tooltip-style={definition.isSource ? NameTooltipStyleSource : NameTooltipStyle}
data-tooltip-style={definition.isMaterializable ? NameTooltipStyle : NameTooltipStyleSource}
style={{overflow: 'hidden', textOverflow: 'ellipsis'}}
>
{withMiddleTruncation(displayName, {
Expand Down Expand Up @@ -208,7 +206,7 @@ export const AssetNodeMinimal = ({
definition: AssetNodeFragment;
height: number;
}) => {
const {isSource, assetKey} = definition;
const {isMaterializable, assetKey} = definition;
const {liveData} = useAssetLiveData(assetKey);

const {border, background} = buildAssetNodeStatusContent({assetKey, definition, liveData});
Expand All @@ -231,7 +229,7 @@ export const AssetNodeMinimal = ({
>
<MinimalAssetNodeBox
$selected={selected}
$isSource={isSource}
$isMaterializable={isMaterializable}
$background={background}
$border={border}
$inProgress={!!inProgressRuns}
Expand All @@ -244,7 +242,7 @@ export const AssetNodeMinimal = ({
/>
) : null}
{isStale ? <MinimalNodeStaleDot assetKey={assetKey} liveData={liveData} /> : null}
<MinimalName style={{fontSize: 24}} $isSource={isSource}>
<MinimalName style={{fontSize: 24}} $isMaterializable={isMaterializable}>
{withMiddleTruncation(displayName, {maxLength: 18})}
</MinimalName>
</MinimalAssetNodeBox>
Expand All @@ -271,7 +269,7 @@ export const ASSET_NODE_FRAGMENT = gql`
computeKind
isPartitioned
isObservable
isSource
isMaterializable
assetKey {
...AssetNodeKey
}
Expand Down Expand Up @@ -307,12 +305,12 @@ const AssetNodeShowOnHover = styled.span`
`;

export const AssetNodeBox = styled.div<{
$isSource: boolean;
$isMaterializable: boolean;
$selected: boolean;
$noScale?: boolean;
}>`
${(p) =>
p.$isSource
!p.$isMaterializable
? `border: 2px dashed ${p.$selected ? Colors.accentGrayHover() : Colors.accentGray()}`
: `border: 2px solid ${
p.$selected ? Colors.lineageNodeBorderSelected() : Colors.lineageNodeBorder()
Expand Down Expand Up @@ -360,11 +358,11 @@ const NameTooltipStyleSource = JSON.stringify({
border: `none`,
});

const AssetName = styled.div<{$isSource: boolean}>`
const AssetName = styled.div<{$isMaterializable: boolean}>`
${NameCSS};
display: flex;
gap: 4px;
background: ${(p) => (p.$isSource ? Colors.backgroundLight() : Colors.lineageNodeBackground())};
background: ${(p) => (p.$isMaterializable ? Colors.lineageNodeBackground() : Colors.backgroundLight())};
border-top-left-radius: 8px;
border-top-right-radius: 8px;
`;
Expand All @@ -374,7 +372,7 @@ const MinimalAssetNodeContainer = styled(AssetNodeContainer)`
`;

const MinimalAssetNodeBox = styled.div<{
$isSource: boolean;
$isMaterializable: boolean;
$selected: boolean;
$background: string;
$border: string;
Expand All @@ -384,7 +382,7 @@ const MinimalAssetNodeBox = styled.div<{
background: ${(p) => p.$background};
overflow: hidden;
${(p) =>
p.$isSource
!p.$isMaterializable
? `border: 4px dashed ${p.$selected ? Colors.accentGray() : p.$border}`
: `border: 4px solid ${p.$selected ? Colors.lineageNodeBorderSelected() : p.$border}`};
${(p) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type AssetNodeMenuNode = {
id: string;
assetKey: AssetKeyInput;
definition: {
isSource: boolean;
isMaterializable: boolean;
isObservable: boolean;
isExecutable: boolean;
hasMaterializePermission: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const LOADING_STATUS_CONTENT = {

export type StatusContentArgs = {
assetKey: AssetKeyInput;
definition: {opNames: string[]; isSource: boolean; isObservable: boolean};
definition: {opNames: string[]; isMaterializable: boolean; isObservable: boolean};
liveData: LiveDataForNode | null | undefined;
expanded?: boolean;
};
Expand Down Expand Up @@ -400,7 +400,7 @@ export function _buildAssetNodeStatusContent({
};
}

if (!lastMaterialization && definition.isSource) {
if (!lastMaterialization && !definition.isMaterializable) {
return {
case: StatusCase.SOURCE_NO_STATE as const,
background: Colors.backgroundLight(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export const SidebarAssetInfo = ({graphNode}: {graphNode: GraphNode}) => {

{assetType && <TypeSidebarSection assetType={assetType} />}

{asset.partitionDefinition && !definition.isSource && (
{asset.partitionDefinition && definition.isMaterializable && (
<SidebarSection title="Partitions">
<Box padding={{vertical: 16, horizontal: 24}} flex={{direction: 'column', gap: 16}}>
<p>{asset.partitionDefinition.description}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const buildGraphNodeMock = (definitionOverrides: Partial<AssetNode>): GraphNode
graphName: null,
isPartitioned: false,
isObservable: false,
isSource: false,
isMaterializable: true,
...definitionOverrides,
}),
});
Expand Down Expand Up @@ -329,7 +329,7 @@ export const AssetWithDifferentOpName = () => {
export const ObservableSourceAsset = () => {
return (
<TestContainer>
<SidebarAssetInfo graphNode={buildGraphNodeMock({isObservable: true, isSource: true})} />
<SidebarAssetInfo graphNode={buildGraphNodeMock({isObservable: true, isMaterializable: false})} />
</TestContainer>
);
};

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

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 @@ -75,10 +75,10 @@ export const AssetEvents = ({
(json) => ({types: json?.types || ALL_EVENT_TYPES}),
);

// Source assets never have materializations, so we don't want to show the type filter
const hideFilters = assetNode?.isSource;
// Source assets never have a partitions tab, so we shouldn't allow links to it
const hidePartitionLinks = assetNode?.isSource;
// No need to show the type filter for assets without materializations
const hideFilters = !assetNode?.isMaterializable;
// Non-materializable assets never have a partitions tab, so we shouldn't allow links to it
const hidePartitionLinks = !assetNode?.isMaterializable;

const grouped = useGroupedEvents(
xAxis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,7 @@ const DescriptionAnnotations = ({
</Mono>
))}
<UnderlyingOpsOrGraph assetNode={assetNode} repoAddress={repoAddress} />
{assetNode.isSource ? (
<Caption style={{lineHeight: '16px'}}>Source Asset</Caption>
) : !assetNode.isExecutable ? (
{!assetNode.isMaterializable ? (
<Caption style={{lineHeight: '16px'}}>External Asset</Caption>
) : undefined}
</Box>
Expand All @@ -313,7 +311,7 @@ export const ASSET_NODE_DEFINITION_FRAGMENT = gql`
opNames
opVersion
jobNames
isSource
isMaterializable
isExecutable
tags {
key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const ASSET_TABLE_DEFINITION_FRAGMENT = gql`
changedReasons
groupName
opNames
isSource
isMaterializable
isObservable
isExecutable
computeKind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const buildAssetTabMap = (input: AssetTabConfigInput) => {
id: 'partitions',
title: 'Partitions',
to: buildAssetViewParams({...params, view: 'partitions'}),
hidden: !definition?.partitionDefinition || definition?.isSource,
hidden: !definition?.partitionDefinition || !definition?.isMaterializable,
} as AssetTabConfig,
checks: {
id: 'checks',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export const AssetView = ({
};

const renderPartitionsTab = () => {
if (definition?.isSource) {
if (!definition?.isMaterializable) {
return <Redirect to={assetDetailsPathForKey(assetKey, {view: 'events'})} />;
}

Expand Down Expand Up @@ -567,9 +567,7 @@ const AssetViewPageHeaderTags = ({
/>
</>
) : null}
{definition?.isSource ? (
<Tag>Source Asset</Tag>
) : !definition?.isExecutable ? (
{!definition?.isMaterializable ? (
<Tag>External Asset</Tag>
) : undefined}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const CalculateUnsyncedDialog = React.memo(
const unsynced = React.useMemo(
() =>
(data?.assetNodes || [])
.filter((node) => !node.isSource && (isAssetStale(node) || isAssetMissing(node)))
.filter((node) => node.isMaterializable && (isAssetStale(node) || isAssetMissing(node)))
.map(asAssetKeyInput),
[data],
);
Expand Down Expand Up @@ -208,7 +208,7 @@ const ASSET_STALE_STATUS_QUERY = gql`
assetKey {
path
}
isSource
isMaterializable
staleStatus
partitionStats {
numMaterialized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ export const LAUNCH_ASSET_WARNINGS_QUERY = gql`
query LaunchAssetWarningsQuery($upstreamAssetKeys: [AssetKeyInput!]!) {
assetNodes(assetKeys: $upstreamAssetKeys) {
id
isSource
isMaterializable
assetKey {
path
}
Expand Down Expand Up @@ -755,7 +755,7 @@ const Warnings = ({
(upstreamAssets || [])
.filter(
(a) =>
!a.isSource &&
a.isMaterializable &&
a.partitionDefinition &&
displayedPartitionDefinition &&
partitionDefinitionsEqual(a.partitionDefinition, displayedPartitionDefinition),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ async function upstreamAssetsWithNoMaterializations(
});

return result.data.assetNodes
.filter((a) => !a.isSource && a.assetMaterializations.length === 0)
.filter((a) => a.isMaterializable && a.assetMaterializations.length === 0)
.map((a) => a.assetKey);
}

Expand Down Expand Up @@ -789,7 +789,7 @@ const LAUNCH_ASSET_EXECUTION_ASSET_NODE_FRAGMENT = gql`
}
isObservable
isExecutable
isSource
isMaterializable
assetKey {
path
}
Expand Down Expand Up @@ -936,7 +936,7 @@ export const LAUNCH_ASSET_CHECK_UPSTREAM_QUERY = gql`
assetKey {
path
}
isSource
isMaterializable
opNames
graphName
assetMaterializations(limit: 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,10 @@ async function stateForObservingAssets(
_forceLaunchpad: boolean,
preferredJobName?: string,
): Promise<ObserveAssetsState> {
if (assets.some((x) => !x.isSource)) {
return {
type: 'error',
error: 'One or more non-source assets are selected and cannot be observed.',
};
}

if (assets.some((x) => !x.isObservable)) {
return {
type: 'error',
error: 'One or more of the selected source assets is not an observable asset.',
error: 'One or more of the selected assets is not an observable asset.',
};
}
const repoAddress = buildRepoAddress(
Expand Down
Loading

0 comments on commit 3d10a43

Please sign in to comment.