Skip to content

Commit

Permalink
[ui] fix job names (#26616)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
dliu27 authored Dec 19, 2024
1 parent d4c99f5 commit e7533d6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -190,22 +190,15 @@ const EvaluateSchedule = ({repoAddress, name, onClose, jobName}: Props) => {

try {
if (executionParamsList) {
await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast', jobName);
await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast');
}
} catch (e) {
console.error(e);
}

setLaunching(false);
onClose();
}, [
canLaunchAll,
executionParamsList,
jobName,
launchMultipleRunsWithTelemetry,
onClose,
trackEvent,
]);
}, [canLaunchAll, executionParamsList, launchMultipleRunsWithTelemetry, onClose, trackEvent]);

const content = useMemo(() => {
// launching all runs state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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) {
Expand All @@ -208,7 +208,6 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop
}, [
canLaunchAll,
executionParamsList,
jobName,
launchMultipleRunsWithTelemetry,
onClose,
onCommitTickResult,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand All @@ -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: [],
Expand All @@ -57,6 +58,7 @@ export const buildExecutionParamsListSensor = (
export const buildExecutionParamsListSchedule = (
scheduleExecutionData: ScheduleDryRunInstigationTick,
scheduleSelector: ScheduleSelector,
jobName: string,
) => {
if (!scheduleExecutionData) {
return [];
Expand All @@ -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: [],
Expand Down

1 comment on commit e7533d6

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-2ijj5jawf-elementl.vercel.app

Built with commit e7533d6.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.