Skip to content

Commit

Permalink
Propagate automation condition information through the UI for user co…
Browse files Browse the repository at this point in the history
…de conditions (dagster-io#25211)

## Summary & Motivation

It is not possible to serialize the full automation condition object if it is user-defined. In these cases, we only persist the snapshot.

Updates the graphql code to use this snapshot instead of the raw condition, and adds e2e test ensuring we can execute / get the correct label for these objects.

## How I Tested These Changes

## Changelog

NOCHANGELOG
  • Loading branch information
OwenKephart authored and Grzyblon committed Oct 26, 2024
1 parent 173b97a commit 5646577
Show file tree
Hide file tree
Showing 28 changed files with 345 additions and 156 deletions.
14 changes: 7 additions & 7 deletions 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
Expand Up @@ -143,7 +143,7 @@ export const ASSET_GROUP_METADATA_QUERY = gql`
query AssetGroupMetadataQuery($selector: AssetGroupSelector!) {
assetNodes(group: $selector) {
id
autoMaterializePolicy {
automationCondition {
__typename
}
}
Expand Down Expand Up @@ -172,7 +172,7 @@ export const AssetGroupTags = ({

if (
automaterializeSensorsFlagState === 'has-global-amp' &&
assetNodes.some((a) => !!a.autoMaterializePolicy)
assetNodes.some((a) => !!a.automationCondition)
) {
return <AutomaterializeDaemonStatusTag />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ export const AssetNodeOverview = ({

if (
attributes.every((props) => isEmptyChildren(props.children)) &&
!cachedOrLiveAssetNode.autoMaterializePolicy
!cachedOrLiveAssetNode.automationCondition
) {
return (
<SectionEmptyState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export const ASSET_TABLE_DEFINITION_FRAGMENT = gql`
dynamicPartitionsDefinitionName
}
}
autoMaterializePolicy {
policyType
automationCondition {
label
expandedLabel
}
description
owners {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type AssetTabConfigInput = {
definition:
| {
isMaterializable: boolean;
autoMaterializePolicy: {__typename: 'AutoMaterializePolicy'} | null | undefined;
automationCondition: {__typename: 'AutomationCondition'} | null | undefined;
partitionDefinition: {__typename: 'PartitionDefinition'} | null | undefined;
}
| null
Expand Down Expand Up @@ -94,7 +94,7 @@ export const buildAssetTabMap = (input: AssetTabConfigInput) => {
title: 'Automation',
to: buildAssetViewParams({...params, view: 'automation'}),
disabled: !definition,
hidden: !definition?.autoMaterializePolicy,
hidden: !definition?.automationCondition,
} as AssetTabConfig,
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ describe('buildAssetTabs', () => {
it('hides auto-materialize tab if no auto-materialize policy', () => {
const hookResult = renderHook(() =>
useAssetTabs({
definition: {...definitionWithPartition, autoMaterializePolicy: null},
definition: {...definitionWithPartition, automationCondition: null},
params,
}),
);
Expand All @@ -272,7 +272,7 @@ describe('buildAssetTabs', () => {
it('hides partitions and auto-materialize tabs if no partitions or auto-materializing', () => {
const hookResult = renderHook(() =>
useAssetTabs({
definition: {...definitionWithoutPartition, autoMaterializePolicy: null},
definition: {...definitionWithoutPartition, automationCondition: null},
params,
}),
);
Expand Down

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.

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 @@ -24,7 +24,7 @@ export const AUTOMATION_ASSET_SELECTION_FRAGMENT = gql`
}
definition {
id
autoMaterializePolicy {
automationCondition {
__typename
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ const AssetSelectionTag = ({
}, [assetSelection.assetsOrError]);

const assetsWithAMP = useMemo(
() => sortedAssets.filter((asset) => !!asset.definition?.autoMaterializePolicy),
() => sortedAssets.filter((asset) => !!asset.definition?.automationCondition),
[sortedAssets],
);
const assetsWithoutAMP = useMemo(
() => sortedAssets.filter((asset) => !asset.definition?.autoMaterializePolicy),
() => sortedAssets.filter((asset) => !asset.definition?.automationCondition),
[sortedAssets],
);

Expand Down

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 @@ -87,7 +87,7 @@ export const JobMetadata = (props: Props) => {
<JobScheduleOrSensorTag job={metadata.job} repoAddress={repoAddress} />
) : null}
<LatestRunTag pipelineName={pipelineName} repoAddress={repoAddress} />
{metadata.assetNodes && metadata.assetNodes.some((a) => !!a.autoMaterializePolicy) && (
{metadata.assetNodes && metadata.assetNodes.some((a) => !!a.automationCondition) && (
<AutomaterializeDaemonStatusTag />
)}
{metadata.runsForAssetScan ? (
Expand Down Expand Up @@ -214,7 +214,7 @@ export const JOB_METADATA_QUERY = gql`
fragment JobMetadataAssetNode on AssetNode {
id
autoMaterializePolicy {
automationCondition {
__typename
}
assetKey {
Expand Down

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.

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 @@ -4,11 +4,9 @@

import graphene
from dagster._core.asset_graph_view.serializable_entity_subset import SerializableEntitySubset
from dagster._core.definitions.declarative_automation.automation_condition import (
AutomationCondition,
)
from dagster._core.definitions.declarative_automation.serialized_objects import (
AutomationConditionEvaluation,
AutomationConditionSnapshot,
)
from dagster._core.definitions.partition import PartitionsDefinition
from dagster._core.scheduler.instigation import AutoMaterializeAssetEvaluationRecord
Expand Down Expand Up @@ -329,13 +327,14 @@ def _flatten_evaluation(


def get_expanded_label(
item: Union[AutomationConditionEvaluation, AutomationCondition], use_label=False
item: Union[AutomationConditionEvaluation, AutomationConditionSnapshot],
use_label=False,
) -> Sequence[str]:
if isinstance(item, AutomationCondition):
if isinstance(item, AutomationConditionSnapshot):
label, name, description, children = (
item.get_label(),
item.name,
item.description,
item.node_snapshot.label,
item.node_snapshot.name,
item.node_snapshot.description,
item.children,
)
else:
Expand Down
Loading

0 comments on commit 5646577

Please sign in to comment.