From e7533d674e0a5ab5920fef6416f959555345812e Mon Sep 17 00:00:00 2001 From: David Liu <48995019+dliu27@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:59:46 -0500 Subject: [PATCH] [ui] fix job names (#26616) ## Summary & Motivation We want to fallback to jobName if its not specified in request.jobName ## How I Tested These Changes Will test in canary, jest --- .../useLaunchMultipleRunsWithTelemetry.ts | 14 ++------------ .../ui-core/src/ticks/EvaluateScheduleDialog.tsx | 15 ++++----------- .../ui-core/src/ticks/SensorDryRunDialog.tsx | 7 +++---- .../ui-core/src/util/buildExecutionParamsList.ts | 6 ++++-- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/launchpad/useLaunchMultipleRunsWithTelemetry.ts b/js_modules/dagster-ui/packages/ui-core/src/launchpad/useLaunchMultipleRunsWithTelemetry.ts index 77b1891f512d6..f9c6f36fe9899 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/launchpad/useLaunchMultipleRunsWithTelemetry.ts +++ b/js_modules/dagster-ui/packages/ui-core/src/launchpad/useLaunchMultipleRunsWithTelemetry.ts @@ -24,26 +24,16 @@ export function useLaunchMultipleRunsWithTelemetry() { const history = useHistory(); return useCallback( - async ( - variables: LaunchMultipleRunsMutationVariables, - behavior: LaunchBehavior, - jobName: string, - ) => { + async (variables: LaunchMultipleRunsMutationVariables, behavior: LaunchBehavior) => { try { const executionParamsList = Array.isArray(variables.executionParamsList) ? variables.executionParamsList : [variables.executionParamsList]; - let jobNames = executionParamsList.map( + const jobNames = executionParamsList.map( (params) => params.selector.jobName || params.selector.pipelineName, ); - // if only executing one job, and jobName isn't defined, fallback to jobName from sensor/schedule - if (executionParamsList.length === 1 && !executionParamsList[0]?.selector?.jobName) { - jobNames = [jobName]; - executionParamsList[0]!.selector.jobName = jobName; - } - if ( jobNames.length !== executionParamsList.length || jobNames.includes(undefined) || diff --git a/js_modules/dagster-ui/packages/ui-core/src/ticks/EvaluateScheduleDialog.tsx b/js_modules/dagster-ui/packages/ui-core/src/ticks/EvaluateScheduleDialog.tsx index 4cb739a3d7447..cdb83e8aa6066 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/ticks/EvaluateScheduleDialog.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/ticks/EvaluateScheduleDialog.tsx @@ -170,9 +170,9 @@ const EvaluateSchedule = ({repoAddress, name, onClose, jobName}: Props) => { const executionParamsList = useMemo( () => scheduleExecutionData && scheduleSelector - ? buildExecutionParamsListSchedule(scheduleExecutionData, scheduleSelector) + ? buildExecutionParamsListSchedule(scheduleExecutionData, scheduleSelector, jobName) : [], - [scheduleSelector, scheduleExecutionData], + [scheduleSelector, scheduleExecutionData, jobName], ); const canLaunchAll = useMemo(() => { @@ -190,7 +190,7 @@ const EvaluateSchedule = ({repoAddress, name, onClose, jobName}: Props) => { try { if (executionParamsList) { - await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast', jobName); + await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast'); } } catch (e) { console.error(e); @@ -198,14 +198,7 @@ const EvaluateSchedule = ({repoAddress, name, onClose, jobName}: Props) => { setLaunching(false); onClose(); - }, [ - canLaunchAll, - executionParamsList, - jobName, - launchMultipleRunsWithTelemetry, - onClose, - trackEvent, - ]); + }, [canLaunchAll, executionParamsList, launchMultipleRunsWithTelemetry, onClose, trackEvent]); const content = useMemo(() => { // launching all runs state diff --git a/js_modules/dagster-ui/packages/ui-core/src/ticks/SensorDryRunDialog.tsx b/js_modules/dagster-ui/packages/ui-core/src/ticks/SensorDryRunDialog.tsx index 83cad592e15a7..d54ec777a3f9a 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/ticks/SensorDryRunDialog.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/ticks/SensorDryRunDialog.tsx @@ -105,9 +105,9 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop const executionParamsList = useMemo( () => sensorExecutionData && sensorSelector - ? buildExecutionParamsListSensor(sensorExecutionData, sensorSelector) + ? buildExecutionParamsListSensor(sensorExecutionData, sensorSelector, jobName) : [], - [sensorSelector, sensorExecutionData], + [sensorSelector, sensorExecutionData, jobName], ); const submitTest = useCallback(async () => { @@ -196,7 +196,7 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop try { if (executionParamsList) { - await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast', jobName); + await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast'); onCommitTickResult(); // persist tick } } catch (e) { @@ -208,7 +208,6 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop }, [ canLaunchAll, executionParamsList, - jobName, launchMultipleRunsWithTelemetry, onClose, onCommitTickResult, diff --git a/js_modules/dagster-ui/packages/ui-core/src/util/buildExecutionParamsList.ts b/js_modules/dagster-ui/packages/ui-core/src/util/buildExecutionParamsList.ts index d5264bf96a6b6..41f621f63f131 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/util/buildExecutionParamsList.ts +++ b/js_modules/dagster-ui/packages/ui-core/src/util/buildExecutionParamsList.ts @@ -15,6 +15,7 @@ const onlyKeyAndValue = ({key, value}: {key: string; value: string}) => ({key, v export const buildExecutionParamsListSensor = ( sensorExecutionData: SensorDryRunInstigationTick, sensorSelector: SensorSelector, + jobName: string, ) => { if (!sensorExecutionData) { return []; @@ -36,7 +37,7 @@ export const buildExecutionParamsListSensor = ( const executionParams: ExecutionParams = { runConfigData: configYamlOrEmpty, selector: { - jobName: request.jobName, // get jobName from runRequest + jobName: request.jobName ?? jobName, // get jobName from runRequest, fallback to jobName repositoryLocationName, repositoryName, assetSelection: [], @@ -57,6 +58,7 @@ export const buildExecutionParamsListSensor = ( export const buildExecutionParamsListSchedule = ( scheduleExecutionData: ScheduleDryRunInstigationTick, scheduleSelector: ScheduleSelector, + jobName: string, ) => { if (!scheduleExecutionData) { return []; @@ -78,7 +80,7 @@ export const buildExecutionParamsListSchedule = ( const executionParams: ExecutionParams = { runConfigData: configYamlOrEmpty, selector: { - jobName: request.jobName, // get jobName from runRequest + jobName: request.jobName ?? jobName, // get jobName from runRequest, fallback to jobName repositoryLocationName, repositoryName, assetSelection: [],