From 19f5b2a589c44c9e9a5a695db1ca209f6fce6aa2 Mon Sep 17 00:00:00 2001 From: gibsondan Date: Wed, 13 Nov 2024 12:49:09 -0600 Subject: [PATCH] use top level resources field in LaunchAssetLoaderResourceQuery (#25895) Summary: Lets us fetch the resources for the job without neccesarily needing to fetch the full job snapshot. Test Plan: Launch an asset job in the UI ## Summary & Motivation ## How I Tested These Changes ## Changelog > Insert changelog entry or delete this section. --- .../dagster-ui/packages/ui-core/client.json | 2 +- .../src/assets/LaunchAssetExecutionButton.tsx | 38 +- .../LaunchAssetExecutionButton.fixtures.ts | 191 +----- .../types/LaunchAssetExecutionButton.types.ts | 581 +----------------- 4 files changed, 42 insertions(+), 770 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/client.json b/js_modules/dagster-ui/packages/ui-core/client.json index 8798a7e035060..e16a02404b4c1 100644 --- a/js_modules/dagster-ui/packages/ui-core/client.json +++ b/js_modules/dagster-ui/packages/ui-core/client.json @@ -31,7 +31,7 @@ "LaunchAssetWarningsQuery": "1924efd011a8fa46372d16674bca736ef10e46d3aff77430b0bd24461359813e", "LaunchAssetLoaderQuery": "ae6a5d5eaf00ec9eeefaf3e7dc85a7710eb3647608aa00e3ded59877a289d645", "LaunchAssetLoaderJobQuery": "112371f3f0c11b7467940b71e83cba8abf678aed019820af94fdee4f99531841", - "LaunchAssetLoaderResourceQuery": "8576f24034a63da1480b19a7c66dc2af2f5d532aa2ba294ffe7bef5ca92e1366", + "LaunchAssetLoaderResourceQuery": "93f4cbee0c4705015eee5d84a5857b1122e1c3fb7e4f4907f541c43ef6d56176", "LaunchAssetCheckUpstreamQuery": "afb78499f0bf86942fc7f1ff7261c34caec2bd1e4aabb05c95a2db6acc811aaa", "OverduePopoverQuery": "3c8359e1adfab8237e4b26508489f07c09b24069373064c6c94d645312ae9296", "RunningBackfillsNoticeQuery": "edaaca1d6474672ae342eb3887f2aed16fbb502b704a603986d21f14bc10ee53", diff --git a/js_modules/dagster-ui/packages/ui-core/src/assets/LaunchAssetExecutionButton.tsx b/js_modules/dagster-ui/packages/ui-core/src/assets/LaunchAssetExecutionButton.tsx index 4bae153a3ec57..1d4f7e2b4c2cd 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/assets/LaunchAssetExecutionButton.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/assets/LaunchAssetExecutionButton.tsx @@ -54,7 +54,6 @@ import {PipelineSelector} from '../graphql/types'; import {AssetLaunchpad} from '../launchpad/LaunchpadRoot'; import {LaunchPipelineExecutionMutationVariables} from '../runs/types/RunUtils.types'; import {testId} from '../testing/testId'; -import {CONFIG_TYPE_SCHEMA_FRAGMENT} from '../typeexplorer/ConfigTypeSchema'; import {buildRepoAddress} from '../workspace/buildRepoAddress'; import {repoAddressAsHumanString} from '../workspace/repoAddressAsString'; import {RepoAddress} from '../workspace/types'; @@ -878,8 +877,8 @@ export const LAUNCH_ASSET_LOADER_RESOURCE_QUERY = gql` $repositoryLocationName: String! $repositoryName: String! ) { - pipelineOrError( - params: { + resourcesOrError( + pipelineSelector: { pipelineName: $pipelineName repositoryName: $repositoryName repositoryLocationName: $repositoryLocationName @@ -894,30 +893,16 @@ export const LAUNCH_ASSET_LOADER_RESOURCE_QUERY = gql` ... on PipelineNotFoundError { message } - ... on Pipeline { - id - modes { - id - resources { - name - description - configField { - name - isRequired - configType { - ...ConfigTypeSchemaFragment - recursiveConfigTypes { - ...ConfigTypeSchemaFragment - } - } - } + ... on ResourceConnection { + resources { + name + configField { + isRequired } } } } } - - ${CONFIG_TYPE_SCHEMA_FRAGMENT} `; export const LAUNCH_ASSET_CHECK_UPSTREAM_QUERY = gql` @@ -959,15 +944,14 @@ async function checkIfResourcesRequireConfig({ repositoryLocationName: repoAddress.location, }, }); - const pipeline = resourceResult.data.pipelineOrError; - if (pipeline.__typename !== 'Pipeline') { + const resourceConnection = resourceResult.data.resourcesOrError; + if (resourceConnection.__typename !== 'ResourceConnection') { return { - error: pipeline.message, + error: resourceConnection.message, requiredConfigPresent: false, }; } - - const resources = pipeline.modes[0]!.resources.filter((r) => + const resources = resourceConnection.resources.filter((r) => requiredResourceKeys.includes(r.name), ); return { diff --git a/js_modules/dagster-ui/packages/ui-core/src/assets/__fixtures__/LaunchAssetExecutionButton.fixtures.ts b/js_modules/dagster-ui/packages/ui-core/src/assets/__fixtures__/LaunchAssetExecutionButton.fixtures.ts index 4a70909d6782d..3d32494405bc5 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/assets/__fixtures__/LaunchAssetExecutionButton.fixtures.ts +++ b/js_modules/dagster-ui/packages/ui-core/src/assets/__fixtures__/LaunchAssetExecutionButton.fixtures.ts @@ -19,7 +19,6 @@ import { buildDimensionPartitionKeys, buildInstance, buildMaterializationEvent, - buildMode, buildPartitionDefinition, buildPartitionRunConfig, buildPartitionTags, @@ -444,16 +443,7 @@ export const buildLaunchAssetLoaderGenericJobMock = (jobName: string) => { result: { data: { __typename: 'Query', - pipelineOrError: { - id: '8e2d3f9597c4a45bb52fe9ab5656419f4329d4fb', - modes: [ - buildMode({ - id: 'da3055161c528f4c839339deb4a362ec1be4f079-default', - resources: [], - }), - ], - __typename: 'Pipeline', - }, + resourcesOrError: {__typename: 'ResourceConnection', resources: []}, }, }, }; @@ -472,84 +462,18 @@ export const LaunchAssetLoaderResourceJob7Mock: MockedResponse; - recursiveConfigTypes: Array< - | { - __typename: 'ArrayConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'CompositeConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - fields: Array<{ - __typename: 'ConfigTypeField'; - name: string; - description: string | null; - isRequired: boolean; - configTypeKey: string; - defaultValueAsJson: string | null; - }>; - } - | { - __typename: 'EnumConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - values: Array<{ - __typename: 'EnumConfigValue'; - value: string; - description: string | null; - }>; - } - | { - __typename: 'MapConfigType'; - keyLabelName: string | null; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'NullableConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'RegularConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'ScalarUnionConfigType'; - scalarTypeKey: string; - nonScalarTypeKey: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - >; - } - | { - __typename: 'CompositeConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - recursiveConfigTypes: Array< - | { - __typename: 'ArrayConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'CompositeConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - fields: Array<{ - __typename: 'ConfigTypeField'; - name: string; - description: string | null; - isRequired: boolean; - configTypeKey: string; - defaultValueAsJson: string | null; - }>; - } - | { - __typename: 'EnumConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - values: Array<{ - __typename: 'EnumConfigValue'; - value: string; - description: string | null; - }>; - } - | { - __typename: 'MapConfigType'; - keyLabelName: string | null; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'NullableConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'RegularConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'ScalarUnionConfigType'; - scalarTypeKey: string; - nonScalarTypeKey: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - >; - fields: Array<{ - __typename: 'ConfigTypeField'; - name: string; - description: string | null; - isRequired: boolean; - configTypeKey: string; - defaultValueAsJson: string | null; - }>; - } - | { - __typename: 'EnumConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - recursiveConfigTypes: Array< - | { - __typename: 'ArrayConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'CompositeConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - fields: Array<{ - __typename: 'ConfigTypeField'; - name: string; - description: string | null; - isRequired: boolean; - configTypeKey: string; - defaultValueAsJson: string | null; - }>; - } - | { - __typename: 'EnumConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - values: Array<{ - __typename: 'EnumConfigValue'; - value: string; - description: string | null; - }>; - } - | { - __typename: 'MapConfigType'; - keyLabelName: string | null; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'NullableConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'RegularConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'ScalarUnionConfigType'; - scalarTypeKey: string; - nonScalarTypeKey: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - >; - values: Array<{ - __typename: 'EnumConfigValue'; - value: string; - description: string | null; - }>; - } - | { - __typename: 'MapConfigType'; - keyLabelName: string | null; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - recursiveConfigTypes: Array< - | { - __typename: 'ArrayConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'CompositeConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - fields: Array<{ - __typename: 'ConfigTypeField'; - name: string; - description: string | null; - isRequired: boolean; - configTypeKey: string; - defaultValueAsJson: string | null; - }>; - } - | { - __typename: 'EnumConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - values: Array<{ - __typename: 'EnumConfigValue'; - value: string; - description: string | null; - }>; - } - | { - __typename: 'MapConfigType'; - keyLabelName: string | null; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'NullableConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'RegularConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'ScalarUnionConfigType'; - scalarTypeKey: string; - nonScalarTypeKey: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - >; - } - | { - __typename: 'NullableConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - recursiveConfigTypes: Array< - | { - __typename: 'ArrayConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'CompositeConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - fields: Array<{ - __typename: 'ConfigTypeField'; - name: string; - description: string | null; - isRequired: boolean; - configTypeKey: string; - defaultValueAsJson: string | null; - }>; - } - | { - __typename: 'EnumConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - values: Array<{ - __typename: 'EnumConfigValue'; - value: string; - description: string | null; - }>; - } - | { - __typename: 'MapConfigType'; - keyLabelName: string | null; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'NullableConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'RegularConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'ScalarUnionConfigType'; - scalarTypeKey: string; - nonScalarTypeKey: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - >; - } - | { - __typename: 'RegularConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - recursiveConfigTypes: Array< - | { - __typename: 'ArrayConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'CompositeConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - fields: Array<{ - __typename: 'ConfigTypeField'; - name: string; - description: string | null; - isRequired: boolean; - configTypeKey: string; - defaultValueAsJson: string | null; - }>; - } - | { - __typename: 'EnumConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - values: Array<{ - __typename: 'EnumConfigValue'; - value: string; - description: string | null; - }>; - } - | { - __typename: 'MapConfigType'; - keyLabelName: string | null; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'NullableConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'RegularConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'ScalarUnionConfigType'; - scalarTypeKey: string; - nonScalarTypeKey: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - >; - } - | { - __typename: 'ScalarUnionConfigType'; - scalarTypeKey: string; - nonScalarTypeKey: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - recursiveConfigTypes: Array< - | { - __typename: 'ArrayConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'CompositeConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - fields: Array<{ - __typename: 'ConfigTypeField'; - name: string; - description: string | null; - isRequired: boolean; - configTypeKey: string; - defaultValueAsJson: string | null; - }>; - } - | { - __typename: 'EnumConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - values: Array<{ - __typename: 'EnumConfigValue'; - value: string; - description: string | null; - }>; - } - | { - __typename: 'MapConfigType'; - keyLabelName: string | null; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'NullableConfigType'; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'RegularConfigType'; - givenName: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - | { - __typename: 'ScalarUnionConfigType'; - scalarTypeKey: string; - nonScalarTypeKey: string; - key: string; - description: string | null; - isSelector: boolean; - typeParamKeys: Array; - } - >; - }; - } | null; - }>; + __typename: 'ResourceConnection'; + resources: Array<{ + __typename: 'Resource'; + name: string; + configField: {__typename: 'ConfigTypeField'; isRequired: boolean} | null; }>; - } - | {__typename: 'PipelineNotFoundError'; message: string} - | {__typename: 'PythonError'; message: string}; + }; }; export type LaunchAssetCheckUpstreamQueryVariables = Types.Exact<{ @@ -2467,6 +1906,6 @@ export const LaunchAssetLoaderQueryVersion = 'ae6a5d5eaf00ec9eeefaf3e7dc85a7710e export const LaunchAssetLoaderJobQueryVersion = '112371f3f0c11b7467940b71e83cba8abf678aed019820af94fdee4f99531841'; -export const LaunchAssetLoaderResourceQueryVersion = '8576f24034a63da1480b19a7c66dc2af2f5d532aa2ba294ffe7bef5ca92e1366'; +export const LaunchAssetLoaderResourceQueryVersion = '93f4cbee0c4705015eee5d84a5857b1122e1c3fb7e4f4907f541c43ef6d56176'; export const LaunchAssetCheckUpstreamQueryVersion = 'afb78499f0bf86942fc7f1ff7261c34caec2bd1e4aabb05c95a2db6acc811aaa';