diff --git a/js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql b/js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql index ce44f8ddf6964..6477ed6df2171 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql +++ b/js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql @@ -3128,7 +3128,6 @@ type Query { beforeTimestamp: Float afterTimestamp: Float ): [InstigationTick!]! - assetChecksOrError(assetKey: AssetKeyInput!, checkName: String): AssetChecksOrError! assetCheckExecutions( assetKey: AssetKeyInput! checkName: String! diff --git a/js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts b/js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts index 602676768ad8f..1b8227f185427 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts +++ b/js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts @@ -2895,7 +2895,6 @@ export type Query = { allTopLevelResourceDetailsOrError: ResourcesOrError; assetBackfillPreview: Array; assetCheckExecutions: Array; - assetChecksOrError: AssetChecksOrError; assetNodeDefinitionCollisions: Array; assetNodeOrError: AssetNodeOrError; assetNodes: Array; @@ -2962,11 +2961,6 @@ export type QueryAssetCheckExecutionsArgs = { limit: Scalars['Int']; }; -export type QueryAssetChecksOrErrorArgs = { - assetKey: AssetKeyInput; - checkName?: InputMaybe; -}; - export type QueryAssetNodeDefinitionCollisionsArgs = { assetKeys?: InputMaybe>; }; @@ -9997,12 +9991,6 @@ export const buildQuery = ( overrides && overrides.hasOwnProperty('assetCheckExecutions') ? overrides.assetCheckExecutions! : [], - assetChecksOrError: - overrides && overrides.hasOwnProperty('assetChecksOrError') - ? overrides.assetChecksOrError! - : relationshipsToOmit.has('AssetCheckNeedsAgentUpgradeError') - ? ({} as AssetCheckNeedsAgentUpgradeError) - : buildAssetCheckNeedsAgentUpgradeError({}, relationshipsToOmit), assetNodeDefinitionCollisions: overrides && overrides.hasOwnProperty('assetNodeDefinitionCollisions') ? overrides.assetNodeDefinitionCollisions! diff --git a/python_modules/dagster-graphql/dagster_graphql/implementation/fetch_asset_checks.py b/python_modules/dagster-graphql/dagster_graphql/implementation/fetch_asset_checks.py index fb0810eb487cb..4c7ea644a1cc0 100644 --- a/python_modules/dagster-graphql/dagster_graphql/implementation/fetch_asset_checks.py +++ b/python_modules/dagster-graphql/dagster_graphql/implementation/fetch_asset_checks.py @@ -14,11 +14,9 @@ from dagster._core.storage.dagster_run import DagsterRunStatus from ..schema.asset_checks import ( - AssetChecksOrErrorUnion, GrapheneAssetCheckExecution, - GrapheneAssetChecks, ) -from .asset_checks_loader import AssetChecksLoader, asset_checks_iter +from .asset_checks_loader import asset_checks_iter if TYPE_CHECKING: from ..schema.util import ResolveInfo @@ -34,23 +32,6 @@ def has_asset_checks( ) -def fetch_asset_checks( - graphene_info: "ResolveInfo", - asset_key: AssetKey, - check_name: Optional[str] = None, -) -> AssetChecksOrErrorUnion: - # use the batched loader with a single asset - loader = AssetChecksLoader(context=graphene_info.context, asset_keys=[asset_key]) - all_checks = loader.get_checks_for_asset(asset_key) - if not check_name or not isinstance(all_checks, GrapheneAssetChecks): - return all_checks - # the only case where we filter by check name is for execution history. We'll make that it's own resolver. - # For now, just filter the checks in the response. - return GrapheneAssetChecks( - checks=[check for check in all_checks.checks if check._asset_check.name == check_name] # noqa: SLF001 - ) - - def _get_asset_check_execution_status( instance: DagsterInstance, execution: AssetCheckExecutionRecord ) -> AssetCheckExecutionResolvedStatus: diff --git a/python_modules/dagster-graphql/dagster_graphql/schema/roots/query.py b/python_modules/dagster-graphql/dagster_graphql/schema/roots/query.py index 5af99951648e0..04dd7112efe8d 100644 --- a/python_modules/dagster-graphql/dagster_graphql/schema/roots/query.py +++ b/python_modules/dagster-graphql/dagster_graphql/schema/roots/query.py @@ -41,7 +41,7 @@ fetch_repository, fetch_workspace, ) -from ...implementation.fetch_asset_checks import fetch_asset_check_executions, fetch_asset_checks +from ...implementation.fetch_asset_checks import fetch_asset_check_executions from ...implementation.fetch_assets import ( get_asset, get_asset_node, @@ -92,7 +92,7 @@ graph_selector_from_graphql, pipeline_selector_from_graphql, ) -from ..asset_checks import GrapheneAssetCheckExecution, GrapheneAssetChecksOrError +from ..asset_checks import GrapheneAssetCheckExecution from ..asset_graph import ( GrapheneAssetLatestInfo, GrapheneAssetNode, @@ -525,14 +525,6 @@ class Meta: description="Fetch the history of auto-materialization ticks", ) - # deprecated. Use assetNode { assetChecksOrError } or assetCheckExecutions instead - assetChecksOrError = graphene.Field( - graphene.NonNull(GrapheneAssetChecksOrError), - assetKey=graphene.Argument(graphene.NonNull(GrapheneAssetKeyInput)), - checkName=graphene.Argument(graphene.String()), - description="Retrieve the asset checks for a given asset key.", - ) - assetCheckExecutions = graphene.Field( non_null_list(GrapheneAssetCheckExecution), assetKey=graphene.Argument(graphene.NonNull(GrapheneAssetKeyInput)), @@ -1131,14 +1123,6 @@ def resolve_autoMaterializeTicks( after=afterTimestamp, ) - def resolve_assetChecksOrError( - self, - graphene_info: ResolveInfo, - assetKey: GrapheneAssetKeyInput, - checkName: Optional[str] = None, - ): - return fetch_asset_checks(graphene_info, AssetKey.from_graphql_input(assetKey), checkName) - def resolve_assetCheckExecutions( self, graphene_info: ResolveInfo, diff --git a/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_asset_checks.py b/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_asset_checks.py index af71314b9c8fc..4eb8b1078844a 100644 --- a/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_asset_checks.py +++ b/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_asset_checks.py @@ -24,48 +24,55 @@ ExecutingGraphQLContextTestMatrix, ) -GET_ASSET_CHECKS = """ -query GetAssetChecksQuery($assetKey: AssetKeyInput!, $checkName: String) { - assetChecksOrError(assetKey: $assetKey, checkName: $checkName) { - ... on AssetChecks { - checks { - name - assetKey { - path +GET_ASSET_CHECK_DETAILS_QUERY = """ +query AssetNodeChecksLimitQuery($assetKeys: [AssetKeyInput!], $limit: Int) { + assetNodes(assetKeys: $assetKeys) { + assetKey { + path + } + assetChecksOrError(limit: $limit) { + ... on AssetChecks { + checks { + name + description + canExecuteIndividually } - description - canExecuteIndividually } } } } """ -GET_ASSET_CHECK_HISTORY = """ -query GetAssetChecksQuery($assetKey: AssetKeyInput!, $checkName: String!) { - assetChecksOrError(assetKey: $assetKey, checkName: $checkName) { - ... on AssetChecks { - checks { - name - executions(limit: 10) { - runId - status - evaluation { - severity - timestamp - targetMaterialization { - storageId - runId - timestamp - } - metadataEntries { - label - } - } +GET_ASSET_CHECK_NAMES_QUERY = """ +query AssetNodeChecksLimitQuery($assetKeys: [AssetKeyInput!], $limit: Int) { + assetNodes(assetKeys: $assetKeys) { + assetKey { + path + } + assetChecksOrError(limit: $limit) { + ... on AssetChecks { + checks { + name } } } } +} +""" + +GET_ASSET_CHECK_HISTORY_WITH_ID = """ +query GetAssetChecksQuery($assetKey: AssetKeyInput!, $checkName: String!, $limit: Int!, $cursor: String) { + assetCheckExecutions(assetKey: $assetKey, checkName: $checkName, limit: $limit, cursor: $cursor) { + id + status + runId + } +} +""" + + +GET_ASSET_CHECK_HISTORY = """ +query GetAssetChecksQuery($assetKey: AssetKeyInput!, $checkName: String!) { assetCheckExecutions(assetKey: $assetKey, checkName: $checkName, limit: 10) { runId status @@ -85,16 +92,17 @@ } """ -GET_ASSET_CHECK_HISTORY_WITH_ID = """ -query GetAssetChecksQuery($assetKey: AssetKeyInput!, $checkName: String, $limit: Int!, $cursor: String) { - assetChecksOrError(assetKey: $assetKey, checkName: $checkName) { - ... on AssetChecks { - checks { - name - executions(limit: $limit, cursor: $cursor) { - id - status - runId +GET_LATEST_EXECUTION = """ +query GetLatestExecution($assetKey: AssetKeyInput!) { + assetNodes(assetKeys: [$assetKey]) { + assetChecksOrError { + ... on AssetChecks { + checks { + name + executionForLatestMaterialization { + runId + status + } } } } @@ -103,18 +111,11 @@ """ GET_ASSET_CHECK_HISTORY_WITH_STEP_KEY = """ -query GetAssetChecksQuery($assetKey: AssetKeyInput!, $checkName: String) { - assetChecksOrError(assetKey: $assetKey, checkName: $checkName) { - ... on AssetChecks { - checks { - name - executions(limit: 10) { - runId - status - stepKey - } - } - } +query GetAssetChecksQuery($assetKey: AssetKeyInput!, $checkName: String!) { + assetCheckExecutions(assetKey: $assetKey, checkName: $checkName, limit: 10) { + runId + status + stepKey } } """ @@ -132,21 +133,6 @@ } """ -GET_LATEST_EXECUTION = """ -query GetLatestExecution($assetKey: AssetKeyInput!) { - assetChecksOrError(assetKey: $assetKey) { - ... on AssetChecks { - checks { - name - executionForLatestMaterialization { - runId - status - } - } - } - } -} -""" LAUNCH_PIPELINE_EXECUTION_MUTATION = ( ERROR_FRAGMENT @@ -229,24 +215,6 @@ """ -ASSET_NODE_CHECKS_QUERY = """ -query AssetNodeChecksLimitQuery($limit: Int) { - assetNodes { - assetKey { - path - } - assetChecksOrError(limit: $limit) { - ... on AssetChecks { - checks { - name - } - } - } - } -} -""" - - def _planned_event(run_id: str, planned: AssetCheckEvaluationPlanned) -> EventLogEntry: return EventLogEntry( error_info=None, @@ -299,45 +267,51 @@ def _materialization_event(run_id: str, asset_key: AssetKey) -> EventLogEntry: class TestAssetChecks(ExecutingGraphQLContextTestMatrix): def test_asset_check_definitions(self, graphql_context: WorkspaceRequestContext): res = execute_dagster_graphql( - graphql_context, GET_ASSET_CHECKS, variables={"assetKey": {"path": ["asset_1"]}} + graphql_context, + GET_ASSET_CHECK_DETAILS_QUERY, + variables={"assetKeys": [{"path": ["asset_1"]}]}, ) assert res.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "assetKey": { - "path": ["asset_1"], - }, - "description": "asset_1 check", - "canExecuteIndividually": "CAN_EXECUTE", - } - ] - } + "assetNodes": [ + { + "assetKey": {"path": ["asset_1"]}, + "assetChecksOrError": { + "checks": [ + { + "name": "my_check", + "description": "asset_1 check", + "canExecuteIndividually": "CAN_EXECUTE", + } + ] + }, + } + ] } res = execute_dagster_graphql( graphql_context, - GET_ASSET_CHECKS, - variables={"assetKey": {"path": ["check_in_op_asset"]}}, + GET_ASSET_CHECK_DETAILS_QUERY, + variables={"assetKeys": {"path": ["check_in_op_asset"]}}, ) assert res.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "assetKey": { - "path": ["check_in_op_asset"], - }, - "description": None, - "canExecuteIndividually": "REQUIRES_MATERIALIZATION", - } - ] - } + "assetNodes": [ + { + "assetKey": {"path": ["check_in_op_asset"]}, + "assetChecksOrError": { + "checks": [ + { + "name": "my_check", + "description": None, + "canExecuteIndividually": "REQUIRES_MATERIALIZATION", + } + ] + }, + } + ] } - def test_asset_check_asset_node(self, graphql_context: WorkspaceRequestContext): - res = execute_dagster_graphql(graphql_context, ASSET_NODE_CHECKS_QUERY) + def test_asset_check_asset_node_limit(self, graphql_context: WorkspaceRequestContext): + res = execute_dagster_graphql(graphql_context, GET_ASSET_CHECK_NAMES_QUERY) with_checks = [ node for node in res.data["assetNodes"] if node["assetChecksOrError"] != {"checks": []} ] @@ -358,9 +332,8 @@ def test_asset_check_asset_node(self, graphql_context: WorkspaceRequestContext): }, ] - def test_asset_check_asset_node_limit(self, graphql_context: WorkspaceRequestContext): res = execute_dagster_graphql( - graphql_context, ASSET_NODE_CHECKS_QUERY, variables={"limit": 1} + graphql_context, GET_ASSET_CHECK_NAMES_QUERY, variables={"limit": 1} ) with_checks = [ node for node in res.data["assetNodes"] if node["assetChecksOrError"] != {"checks": []} @@ -406,9 +379,7 @@ def test_asset_check_execution_cursoring(self, graphql_context: WorkspaceRequest ) assert res.data expected_run_ids = list(reversed(run_ids))[:expected_limit] - for expected_run_id, execution in zip( - expected_run_ids, res.data["assetChecksOrError"]["checks"][0]["executions"] - ): + for expected_run_id, execution in zip(expected_run_ids, res.data["assetCheckExecutions"]): assert execution["runId"] == expected_run_id res = execute_dagster_graphql( @@ -418,14 +389,12 @@ def test_asset_check_execution_cursoring(self, graphql_context: WorkspaceRequest "assetKey": {"path": ["asset_1"]}, "checkName": "my_check", "limit": expected_limit, - "cursor": res.data["assetChecksOrError"]["checks"][0]["executions"][-1]["id"], + "cursor": res.data["assetCheckExecutions"][-1]["id"], }, ) assert res.data expected_run_ids = list(reversed(run_ids))[expected_limit:] - for expected_run_id, execution in zip( - expected_run_ids, res.data["assetChecksOrError"]["checks"][0]["executions"] - ): + for expected_run_id, execution in zip(expected_run_ids, res.data["assetCheckExecutions"]): assert execution["runId"] == expected_run_id def test_asset_check_executions(self, graphql_context: WorkspaceRequestContext): @@ -446,20 +415,6 @@ def test_asset_check_executions(self, graphql_context: WorkspaceRequestContext): variables={"assetKey": {"path": ["asset_1"]}, "checkName": "my_check"}, ) assert res.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "executions": [ - { - "runId": "foo", - "status": "IN_PROGRESS", - "evaluation": None, - } - ], - } - ] - }, "assetCheckExecutions": [ { "runId": "foo", @@ -494,31 +449,6 @@ def test_asset_check_executions(self, graphql_context: WorkspaceRequestContext): variables={"assetKey": {"path": ["asset_1"]}, "checkName": "my_check"}, ) assert res.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "executions": [ - { - "runId": "foo", - "status": "SUCCEEDED", - "evaluation": { - "timestamp": evaluation_timestamp, - "severity": "ERROR", - "targetMaterialization": { - "storageId": 42, - "runId": "bizbuz", - "timestamp": 3.3, - }, - "metadataEntries": [ - {"label": "foo"}, - ], - }, - } - ], - } - ], - }, "assetCheckExecutions": [ { "runId": "foo", @@ -599,20 +529,6 @@ def test_asset_check_failure(self, graphql_context: WorkspaceRequestContext): variables={"assetKey": {"path": ["asset_1"]}, "checkName": "my_check"}, ) assert res.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "executions": [ - { - "runId": run.run_id, - "status": "IN_PROGRESS", - "evaluation": None, - } - ], - } - ] - }, "assetCheckExecutions": [ { "runId": run.run_id, @@ -630,16 +546,6 @@ def test_asset_check_failure(self, graphql_context: WorkspaceRequestContext): variables={"assetKey": {"path": ["asset_1"]}, "checkName": "my_check"}, ) assert res.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "executions": [ - {"runId": run.run_id, "status": "EXECUTION_FAILED", "evaluation": None} - ], - } - ], - }, "assetCheckExecutions": [ {"runId": run.run_id, "status": "EXECUTION_FAILED", "evaluation": None} ], @@ -659,9 +565,15 @@ def new_materialization() -> EventLogRecord: graphql_context, GET_LATEST_EXECUTION, variables={"assetKey": {"path": ["asset_1"]}} ) assert res.data == { - "assetChecksOrError": { - "checks": [{"name": "my_check", "executionForLatestMaterialization": None}], - } + "assetNodes": [ + { + "assetChecksOrError": { + "checks": [ + {"name": "my_check", "executionForLatestMaterialization": None} + ] + } + } + ] }, "new materialization should clear latest execution" records = instance.get_asset_records([AssetKey(["asset_1"])]) assert records @@ -680,34 +592,42 @@ def new_materialization() -> EventLogRecord: graphql_context, GET_LATEST_EXECUTION, variables={"assetKey": {"path": ["asset_1"]}} ) assert res.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "executionForLatestMaterialization": { - "runId": run.run_id, - "status": "IN_PROGRESS", - }, + "assetNodes": [ + { + "assetChecksOrError": { + "checks": [ + { + "name": "my_check", + "executionForLatestMaterialization": { + "runId": run.run_id, + "status": "IN_PROGRESS", + }, + } + ] } - ] - } + } + ] } instance.report_run_failed(run) res = execute_dagster_graphql( graphql_context, GET_LATEST_EXECUTION, variables={"assetKey": {"path": ["asset_1"]}} ) assert res.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "executionForLatestMaterialization": { - "runId": run.run_id, - "status": "EXECUTION_FAILED", - }, - } - ], - } + "assetNodes": [ + { + "assetChecksOrError": { + "checks": [ + { + "name": "my_check", + "executionForLatestMaterialization": { + "runId": run.run_id, + "status": "EXECUTION_FAILED", + }, + } + ] + }, + } + ] } materialization_record = new_materialization() @@ -724,17 +644,21 @@ def new_materialization() -> EventLogRecord: graphql_context, GET_LATEST_EXECUTION, variables={"assetKey": {"path": ["asset_1"]}} ) assert res.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "executionForLatestMaterialization": { - "runId": run.run_id, - "status": "IN_PROGRESS", - }, - } - ], - } + "assetNodes": [ + { + "assetChecksOrError": { + "checks": [ + { + "name": "my_check", + "executionForLatestMaterialization": { + "runId": run.run_id, + "status": "IN_PROGRESS", + }, + } + ] + }, + } + ] } instance.event_log_storage.store_event( _evaluation_event( @@ -757,17 +681,21 @@ def new_materialization() -> EventLogRecord: graphql_context, GET_LATEST_EXECUTION, variables={"assetKey": {"path": ["asset_1"]}} ) assert res.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "executionForLatestMaterialization": { - "runId": run.run_id, - "status": "SUCCEEDED", - }, - } - ], - } + "assetNodes": [ + { + "assetChecksOrError": { + "checks": [ + { + "name": "my_check", + "executionForLatestMaterialization": { + "runId": run.run_id, + "status": "SUCCEEDED", + }, + } + ] + }, + } + ] } materialization_record = new_materialization() @@ -801,17 +729,21 @@ def new_materialization() -> EventLogRecord: graphql_context, GET_LATEST_EXECUTION, variables={"assetKey": {"path": ["asset_1"]}} ) assert res.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "executionForLatestMaterialization": { - "runId": run.run_id, - "status": "SUCCEEDED", - }, - } - ], - } + "assetNodes": [ + { + "assetChecksOrError": { + "checks": [ + { + "name": "my_check", + "executionForLatestMaterialization": { + "runId": run.run_id, + "status": "SUCCEEDED", + }, + } + ] + }, + } + ] } instance.event_log_storage.store_event( _materialization_event(run.run_id, AssetKey(["asset_1"])) @@ -820,18 +752,23 @@ def new_materialization() -> EventLogRecord: graphql_context, GET_LATEST_EXECUTION, variables={"assetKey": {"path": ["asset_1"]}} ) assert res.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "executionForLatestMaterialization": { - "runId": run.run_id, - "status": "SUCCEEDED", - }, - } - ], - } + "assetNodes": [ + { + "assetChecksOrError": { + "checks": [ + { + "name": "my_check", + "executionForLatestMaterialization": { + "runId": run.run_id, + "status": "SUCCEEDED", + }, + } + ] + }, + } + ] } + new_materialization() def test_launch_subset_with_only_check(self, graphql_context: WorkspaceRequestContext): @@ -1315,18 +1252,11 @@ def test_step_key(self, graphql_context: WorkspaceRequestContext): ) print(result.data) # noqa: T201 assert result.data == { - "assetChecksOrError": { - "checks": [ - { - "name": "my_check", - "executions": [ - { - "runId": run_id, - "status": "SUCCEEDED", - "stepKey": "subsettable_checked_multi_asset", - } - ], - } - ], - } + "assetCheckExecutions": [ + { + "runId": run_id, + "status": "SUCCEEDED", + "stepKey": "subsettable_checked_multi_asset", + } + ], }