Skip to content

Commit

Permalink
[ui] use jobName as fallback if only launching 1 job (#26597)
Browse files Browse the repository at this point in the history
## Summary & Motivation
https://dagsterlabs.slack.com/archives/C06QU0WBCQ5/p1734625511029539

## How I Tested These Changes
Will test in dogfood replicating this situation
  • Loading branch information
dliu27 authored Dec 19, 2024
1 parent 40807bf commit c9233e2
Show file tree
Hide file tree
Showing 9 changed files with 377 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,26 @@ export function useLaunchMultipleRunsWithTelemetry() {
const history = useHistory();

return useCallback(
async (variables: LaunchMultipleRunsMutationVariables, behavior: LaunchBehavior) => {
async (
variables: LaunchMultipleRunsMutationVariables,
behavior: LaunchBehavior,
jobName: string,
) => {
try {
const executionParamsList = Array.isArray(variables.executionParamsList)
? variables.executionParamsList
: [variables.executionParamsList];
const jobNames = executionParamsList.map(

let 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 @@ -17,7 +17,7 @@ interface Props {
runConfigYaml: string;
mode: string | null;
isJob: boolean;

jobName?: string;
// Optionally provide tags to display them as well.
tags?: RunTagsFragment[];

Expand All @@ -27,8 +27,18 @@ interface Props {
}

export const RunConfigDialog = (props: Props) => {
const {isOpen, onClose, copyConfig, runConfigYaml, tags, mode, isJob, request, repoAddress} =
props;
const {
isOpen,
onClose,
copyConfig,
runConfigYaml,
tags,
mode,
isJob,
jobName,
request,
repoAddress,
} = props;
const hasTags = !!tags && tags.length > 0;

return (
Expand Down Expand Up @@ -76,10 +86,12 @@ export const RunConfigDialog = (props: Props) => {
topBorder
left={
request &&
repoAddress && (
repoAddress &&
jobName && (
<OpenInLaunchpadButton
request={request}
mode={mode || null}
jobName={jobName}
isJob={isJob}
repoAddress={repoAddress}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const RunRequestTable = ({runRequests, isJob, repoAddress, mode, jobName}
runConfigYaml={selectedRequest.runConfigYaml}
tags={selectedRequest.tags}
isJob={isJob}
jobName={jobName}
request={selectedRequest}
repoAddress={repoAddress}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,22 @@ const EvaluateSchedule = ({repoAddress, name, onClose, jobName}: Props) => {

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

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

const content = useMemo(() => {
// launching all runs state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop

try {
if (executionParamsList) {
await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast');
await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast', jobName);
onCommitTickResult(); // persist tick
}
} catch (e) {
Expand All @@ -208,6 +208,7 @@ 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 @@ -79,6 +79,44 @@ export const scheduleDryWithWithRunRequest = {
}),
};

export const scheduleDryWithWithRunRequestUndefinedName = {
__typename: 'Mutation' as const,
scheduleDryRun: buildDryRunInstigationTick({
timestamp: 1674950400,
evaluationResult: buildTickEvaluation({
runRequests: [
buildRunRequest({
jobName: undefined,
runConfigYaml:
'ops:\n configurable_op:\n config:\n scheduled_date: 2023-01-29\n',
tags: [
buildPipelineTag({
key: 'dagster/schedule_name',
value: 'configurable_job_schedule',
}),
buildPipelineTag({
key: 'date',
value: '2023-01-29',
__typename: 'PipelineTag' as const,
}),
buildPipelineTag({
key: 'github_test',
value: 'test',
}),
buildPipelineTag({
key: 'okay_t2',
value: 'okay',
}),
],
runKey: 'EvaluateScheduleDialog.test.tsx:1675705668.993122345',
}),
],
skipReason: null,
error: null,
}),
}),
};

export const ScheduleDryRunMutationRunRequests: MockedResponse<ScheduleDryRunMutation> = {
request: {
query: SCHEDULE_DRY_RUN_MUTATION,
Expand All @@ -94,6 +132,22 @@ export const ScheduleDryRunMutationRunRequests: MockedResponse<ScheduleDryRunMut
result: {data: scheduleDryWithWithRunRequest},
};

export const ScheduleDryRunMutationRunRequestsWithUndefinedName: MockedResponse<ScheduleDryRunMutation> =
{
request: {
query: SCHEDULE_DRY_RUN_MUTATION,
variables: {
selectorData: {
scheduleName: 'test',
repositoryLocationName: 'testLocation',
repositoryName: 'testName',
},
timestamp: 5,
},
},
result: {data: scheduleDryWithWithRunRequestUndefinedName},
};

export const ScheduleDryRunMutationError: MockedResponse<ScheduleDryRunMutation> = {
request: {
query: SCHEDULE_DRY_RUN_MUTATION,
Expand Down Expand Up @@ -253,3 +307,87 @@ export const ScheduleLaunchAllMutation: MockedResponse<LaunchMultipleRunsMutatio
},
},
};

export const ScheduleLaunchAllMutationWithUndefinedName: MockedResponse<LaunchMultipleRunsMutation> =
{
request: {
query: LAUNCH_MULTIPLE_RUNS_MUTATION,
variables: {
executionParamsList: [
{
runConfigData:
'ops:\n configurable_op:\n config:\n scheduled_date: 2023-01-29',
selector: {
jobName: 'testJobName', // fallback
repositoryLocationName: 'testLocation',
repositoryName: 'testName',
assetSelection: [],
assetCheckSelection: [],
solidSelection: undefined,
},
mode: 'default',
executionMetadata: {
tags: [
{
key: 'dagster/schedule_name',
value: 'configurable_job_schedule',
},
{
key: 'date',
value: '2023-01-29',
},
{
key: 'github_test',
value: 'test',
},
{
key: 'okay_t2',
value: 'okay',
},
],
},
},
],
},
},
result: {
data: {
__typename: 'Mutation',
launchMultipleRuns: buildLaunchMultipleRunsResult({
launchMultipleRunsResult: [
buildLaunchRunSuccess({
run: buildRun({
id: '504b3a77-d6c4-440c-a128-7f59c9d75d59',
pipeline: buildPipelineSnapshot({
name: 'testJobName', // fallback
}),
tags: [
buildPipelineTag({
key: 'dagster/schedule_name',
value: 'configurable_job_schedule',
}),
buildPipelineTag({
key: 'date',
value: '2023-01-29',
}),
buildPipelineTag({
key: 'github_test',
value: 'test',
}),
buildPipelineTag({
key: 'okay_t2',
value: 'okay',
}),
],
status: RunStatus.QUEUED,
runConfigYaml:
'ops:\n configurable_op:\n config:\n scheduled_date: 2023-01-29',
mode: 'default',
resolvedOpSelection: null,
}),
}),
],
}),
},
},
};
Loading

1 comment on commit c9233e2

@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-8xecv6f6g-elementl.vercel.app

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

Please sign in to comment.