Skip to content

Commit 9e354d0

Browse files
committed
fixup! Show current task executions in the UI
The UI compared region_id with the all-zero placeholder UUID (and Gantt kept its own copy of the constant) to tell a task instance outside every region from one inside a region. The API now omits region_id and region_index for the former, so absence means no region and the UI no longer defines or compares against the placeholder. Link builders, bulk-action requests, the log link, the duration chart and the Run page send or build region parameters only when the response carries them, and the XCom and Run page tables do the same. The Gantt "latest try" key used region_index, which for a mapped slot without a region was the slot's map index. With that field omitted every slot of such a task would share one key and an older try could be pinned against another slot's newer one, so the key now includes the map index. The asset state store link for a writer outside any region can no longer be an exact-try link, because that view is addressed by region parameters; it links to the task instance page. Test fixtures drop the placeholder: ordinary task instances are built without region fields, and the Gantt and Events cases that exercised the placeholder are folded into the no-region case. That includes fixtures in test files that earlier layers introduced.
1 parent 6ddc251 commit 9e354d0

22 files changed

Lines changed: 81 additions & 143 deletions

‎airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearExecutionDialog.tsx‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,7 @@ export const ClearExecutionDialog = ({
113113
dagLevelConfig: dagDetails?.rerun_with_latest_version,
114114
fallback: dagVersionsDiffer,
115115
});
116-
const mappedIds = executions
117-
.filter(
118-
(ti) =>
119-
ti.map_index >= 0 ||
120-
(ti.region_id !== "00000000-0000-0000-0000-000000000000" && ti.region_index === -1),
121-
)
122-
.map((ti) => ti.id);
116+
const mappedIds = executions.filter((ti) => ti.map_index >= 0 || ti.region_index === -1).map((ti) => ti.id);
123117
const requestBody: ClearTaskInstancesBody = {
124118
dag_run_id: runId,
125119
include_downstream: downstream,

‎airflow-core/src/airflow/ui/src/components/Clear/TaskInstance/ClearTaskInstanceDialog.test.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ const taskInstance: TaskInstanceResponse = {
5757
priority_weight: null,
5858
queue: null,
5959
queued_when: null,
60-
region_id: "00000000-0000-0000-0000-000000000000",
61-
region_index: -1,
6260
rendered_fields: undefined,
6361
rendered_map_index: null,
6462
run_after: "2025-01-01T00:00:00Z",

‎airflow-core/src/airflow/ui/src/components/DurationChart.tsx‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -217,19 +217,16 @@ export const DurationChart = ({
217217
runId: entry.dag_run_id,
218218
taskId: entry.task_id,
219219
});
220-
const query = new URLSearchParams({
221-
region_id: entry.region_id,
222-
region_index: String(entry.region_index),
223-
try_number: String(entry.try_number),
224-
});
220+
const query =
221+
entry.region_id === undefined
222+
? undefined
223+
: new URLSearchParams({
224+
region_id: entry.region_id,
225+
region_index: String(entry.region_index),
226+
try_number: String(entry.try_number),
227+
});
225228

226-
void Promise.resolve(
227-
navigate(
228-
entry.region_id === "00000000-0000-0000-0000-000000000000"
229-
? baseUrl
230-
: `${baseUrl}?${query}`,
231-
),
232-
);
229+
void Promise.resolve(navigate(query === undefined ? baseUrl : `${baseUrl}?${query}`));
233230
break;
234231
}
235232
default:

‎airflow-core/src/airflow/ui/src/components/MarkAs/TaskInstance/MarkTaskInstanceAsDialog.test.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ const taskInstance: TaskInstanceResponse = {
8787
priority_weight: null,
8888
queue: null,
8989
queued_when: null,
90-
region_id: "00000000-0000-0000-0000-000000000000",
91-
region_index: 0,
9290
rendered_fields: undefined,
9391
rendered_map_index: null,
9492
run_after: "2025-01-01T00:00:00Z",

‎airflow-core/src/airflow/ui/src/components/TaskInstanceTooltip.test.tsx‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ describe("TaskInstanceTooltip", () => {
9797
priority_weight: null,
9898
queue: null,
9999
queued_when: null,
100-
region_id: "00000000-0000-0000-0000-000000000000",
101-
region_index: 0,
102100
rendered_fields: undefined,
103101
rendered_map_index: null,
104102
run_after: twoHoursAgo,

‎airflow-core/src/airflow/ui/src/layouts/Details/Gantt/GanttTimeline.test.tsx‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,7 @@ describe("GanttTimeline segment bars", () => {
115115
});
116116

117117
it.each([
118-
{
119-
name: "ordinary task",
120-
node: BASE_NODE,
121-
regionId: "00000000-0000-0000-0000-000000000000",
122-
regionIndex: -1,
123-
},
124-
{
125-
name: "legacy mapped slot",
126-
node: BASE_NODE,
127-
regionId: "00000000-0000-0000-0000-000000000000",
128-
regionIndex: 2,
129-
},
118+
{ name: "ordinary task", node: BASE_NODE, regionId: undefined, regionIndex: undefined },
130119
{
131120
name: "mapped aggregate",
132121
node: { ...BASE_NODE, is_mapped: true },

‎airflow-core/src/airflow/ui/src/layouts/Details/Gantt/utils.test.ts‎

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ describe("transformGanttData", () => {
139139
},
140140
},
141141
{
142-
name: "links the sentinel region without region or try selectors for the latest try",
143-
regionId: "00000000-0000-0000-0000-000000000000",
142+
name: "links mapped slots outside any region without region or try selectors for the latest try",
143+
regionId: undefined,
144144
search: { "execution-0-1": "try_number=1", "execution-0-2": "", "execution-2-1": "" },
145145
},
146146
])("$name", ({ regionId, search }) => {
@@ -151,10 +151,9 @@ describe("transformGanttData", () => {
151151
].map(({ index, tryNumber }) => ({
152152
end_date: "2024-03-14T10:05:00Z",
153153
id: `execution-${index}-${tryNumber}`,
154-
map_index: -1,
154+
map_index: regionId === undefined ? index : -1,
155155
queued_dttm: null,
156-
region_id: regionId,
157-
region_index: index,
156+
...(regionId === undefined ? {} : { region_id: regionId, region_index: index }),
158157
scheduled_dttm: null,
159158
start_date: "2024-03-14T10:00:00Z",
160159
state: "success" as const,
@@ -195,8 +194,6 @@ describe("transformGanttData", () => {
195194
is_mapped: false,
196195
map_index: -1,
197196
queued_dttm: null,
198-
region_id: "00000000-0000-0000-0000-000000000000",
199-
region_index: -1,
200197
scheduled_dttm: null,
201198
start_date: null,
202199
state: null,
@@ -222,8 +219,6 @@ describe("transformGanttData", () => {
222219
is_mapped: false,
223220
map_index: -1,
224221
queued_dttm: null,
225-
region_id: "00000000-0000-0000-0000-000000000000",
226-
region_index: -1,
227222
scheduled_dttm: null,
228223
start_date: "2024-03-14T10:00:00+00:00",
229224
state: "running",
@@ -271,8 +266,6 @@ describe("transformGanttData", () => {
271266
is_mapped: false,
272267
map_index: -1,
273268
queued_dttm: null,
274-
region_id: "00000000-0000-0000-0000-000000000000",
275-
region_index: -1,
276269
scheduled_dttm: null,
277270
start_date: "2024-03-14T10:00:00+00:00",
278271
state: "success",
@@ -300,8 +293,6 @@ describe("transformGanttData", () => {
300293
is_mapped: false,
301294
map_index: -1,
302295
queued_dttm: "2024-03-14T09:59:00+00:00",
303-
region_id: "00000000-0000-0000-0000-000000000000",
304-
region_index: -1,
305296
scheduled_dttm: "2024-03-14T09:58:00+00:00",
306297
start_date: "2024-03-14T10:00:00+00:00",
307298
state: "success",
@@ -329,8 +320,6 @@ describe("transformGanttData", () => {
329320
is_mapped: false,
330321
map_index: -1,
331322
queued_dttm: "2024-03-14T09:59:00+00:00",
332-
region_id: "00000000-0000-0000-0000-000000000000",
333-
region_index: -1,
334323
scheduled_dttm: "2024-03-14T09:58:00+00:00",
335324
start_date: "2024-03-14T10:00:00+00:00",
336325
state: "success",
@@ -368,8 +357,6 @@ describe("transformGanttData", () => {
368357
is_mapped: false,
369358
map_index: -1,
370359
queued_dttm: "2024-03-14T09:59:00+00:00",
371-
region_id: "00000000-0000-0000-0000-000000000000",
372-
region_index: -1,
373360
scheduled_dttm: null,
374361
start_date: "2024-03-14T10:00:00+00:00",
375362
state: "running",
@@ -401,8 +388,6 @@ describe("transformGanttData", () => {
401388
is_mapped: false,
402389
map_index: -1,
403390
queued_dttm: "2024-03-14T09:59:00+00:00",
404-
region_id: "00000000-0000-0000-0000-000000000000",
405-
region_index: -1,
406391
scheduled_dttm: null,
407392
start_date: "2024-03-14T10:00:00+00:00",
408393
state: "success",
@@ -429,8 +414,6 @@ describe("transformGanttData", () => {
429414
is_mapped: false,
430415
map_index: -1,
431416
queued_dttm: null,
432-
region_id: "00000000-0000-0000-0000-000000000000",
433-
region_index: -1,
434417
scheduled_dttm: null,
435418
start_date: "2024-03-14T10:00:00+00:00",
436419
state: "success",
@@ -456,8 +439,6 @@ describe("transformGanttData", () => {
456439
is_mapped: false,
457440
map_index: -1,
458441
queued_dttm: null,
459-
region_id: "00000000-0000-0000-0000-000000000000",
460-
region_index: -1,
461442
scheduled_dttm: null,
462443
start_date: "2024-03-14T10:00:00+00:00",
463444
state: "failed",
@@ -471,8 +452,6 @@ describe("transformGanttData", () => {
471452
is_mapped: false,
472453
map_index: -1,
473454
queued_dttm: null,
474-
region_id: "00000000-0000-0000-0000-000000000000",
475-
region_index: -1,
476455
scheduled_dttm: null,
477456
start_date: "2024-03-14T09:50:00+00:00",
478457
state: "failed",

‎airflow-core/src/airflow/ui/src/layouts/Details/Gantt/utils.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export type GanttDataItem = {
3434
end_when?: string | null;
3535
isGroup?: boolean | null;
3636
isMapped?: boolean | null;
37+
mapIndex?: number;
3738
/** Source try times for tooltips (matches TaskInstance `*_when` fields). */
3839
queued_when?: string | null;
3940
regionId?: string;
@@ -146,6 +147,7 @@ export const transformGanttData = ({
146147
endDate ?? (hasTaskRunning && startDate !== null ? new Date().toISOString() : null);
147148

148149
const tryMetadata = {
150+
mapIndex: tryRow.map_index,
149151
regionId: tryRow.region_id,
150152
regionIndex: tryRow.region_index,
151153
taskInstanceId: tryRow.id,
@@ -290,10 +292,8 @@ export const computeGanttTimeRangeMs = ({
290292
};
291293
};
292294

293-
const SENTINEL_REGION_ID = "00000000-0000-0000-0000-000000000000";
294-
295-
const getGanttTryKey = ({ regionId, regionIndex, taskId }: GanttDataItem) =>
296-
`${taskId}:${regionId ?? ""}:${regionIndex ?? -1}`;
295+
const getGanttTryKey = ({ mapIndex, regionId, regionIndex, taskId }: GanttDataItem) =>
296+
`${taskId}:${regionId ?? ""}:${regionIndex ?? -1}:${mapIndex ?? -1}`;
297297

298298
/**
299299
* Precompute the maximum try number for each task and region in O(n).
@@ -337,7 +337,7 @@ export const getGanttSegmentTo = ({
337337
// Clone the pre-parsed params so mutations don't leak across segments.
338338
const searchParams = new URLSearchParams(baseSearchParams);
339339

340-
if (item.regionId !== undefined && item.regionIndex !== undefined && item.regionId !== SENTINEL_REGION_ID) {
340+
if (item.regionId !== undefined && item.regionIndex !== undefined) {
341341
searchParams.set("region_id", item.regionId);
342342
searchParams.set("region_index", item.regionIndex.toString());
343343
} else {

‎airflow-core/src/airflow/ui/src/pages/Asset/AssetStateStore/AssetStateStore.test.tsx‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,9 @@ afterEach(() => vi.restoreAllMocks());
4545

4646
it.each([
4747
{
48-
expected:
49-
"/dags/dag/runs/run/tasks/work?region_id=00000000-0000-0000-0000-000000000000&region_index=-1&try_number=2",
50-
identity: {
51-
region_id: "00000000-0000-0000-0000-000000000000",
52-
region_index: -1,
53-
try_number: 2,
54-
},
55-
label: "retained sentinel writer",
48+
expected: "/dags/dag/runs/run/tasks/work",
49+
identity: { try_number: 2 },
50+
label: "writer outside any region",
5651
mapIndex: -1,
5752
},
5853
{

‎airflow-core/src/airflow/ui/src/pages/Events/Events.tsx‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,7 @@ export const Events = () => {
187187
const { t: translate } = useTranslation(["browse", "common"]);
188188
const { dagId, mapIndex = "-1", runId, taskId } = useParams();
189189
const coordinates = useTaskInstanceCoordinates();
190-
const regional =
191-
taskId !== undefined &&
192-
coordinates.regionId !== undefined &&
193-
coordinates.regionId !== "00000000-0000-0000-0000-000000000000";
190+
const regional = taskId !== undefined && coordinates.regionId !== undefined;
194191
const { data: selectedTask } = useTaskInstanceServiceGetMappedTaskInstance(
195192
{
196193
...coordinates,

0 commit comments

Comments
 (0)