From 6170b022b8f7644036d045eb0d905d53d7012f85 Mon Sep 17 00:00:00 2001 From: Marco polo Date: Wed, 12 Jun 2024 14:39:52 -1000 Subject: [PATCH] Fix Run Timeline splitting out ad hoc jobs (#22520) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary & Motivation https://dagsterlabs.slack.com/archives/C070G3UNNLW/p1718238323769339?thread_ts=1718238288.884269&cid=C070G3UNNLW before: multiple rows for adhoc materializations Screenshot 2024-06-12 at 8 36 48 PM after: just a single one: Screenshot 2024-06-12 at 8 37 01 PM --- .../packages/ui-core/src/runs/useRunsForTimeline.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/runs/useRunsForTimeline.tsx b/js_modules/dagster-ui/packages/ui-core/src/runs/useRunsForTimeline.tsx index ccdf487d0e3ad..755b01b1530d0 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/runs/useRunsForTimeline.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/runs/useRunsForTimeline.tsx @@ -406,6 +406,7 @@ export const useRunsForTimeline = ({ if (!workspaceOrError || workspaceOrError.__typename === 'PythonError' || _end < Date.now()) { return jobsWithCompletedRunsAndOngoingRunsValues; } + const addedAdHocJobs = new Set(); const jobs: TimelineJob[] = []; for (const locationEntry of workspaceOrError.locationEntries) { if ( @@ -450,6 +451,13 @@ export const useRunsForTimeline = ({ const isAdHoc = isHiddenAssetGroupJob(pipeline.name); const jobKey = makeJobKey(repoAddress, pipeline.name); + if (isAdHoc) { + if (addedAdHocJobs.has(jobKey)) { + continue; + } + addedAdHocJobs.add(jobKey); + } + const jobName = isAdHoc ? 'Ad hoc materializations' : pipeline.name; const jobRuns = Object.values(runsByJobKey[jobKey] || {}); @@ -553,7 +561,9 @@ export const useRunsForTimeline = ({ }; export const makeJobKey = (repoAddress: RepoAddress, jobName: string) => - `${jobName}-${repoAddressAsHumanString(repoAddress)}`; + `${isHiddenAssetGroupJob(jobName) ? '__adhoc__' : jobName}-${repoAddressAsHumanString( + repoAddress, + )}`; const RUN_TIMELINE_FRAGMENT = gql` fragment RunTimelineFragment on Run {