Skip to content

Commit f370264

Browse files
noeunkimHsiuChuanHsu
authored andcommitted
Add run_id_pattern search for Dag Run API. (apache#52437)
* Add run_id filter for dag runs * Update i18n support for run_id filter in Dag Runs page * Apply param dependency injection and update i18n key structure * Apply _SearchParam to support pattern search * Rename run_id to run_id_pattern and refactor DagRuns ui to use SearchBar * Resolve merge conflict * Improve test cases * Resolve test failure * Fix: resolve Advanced Search button visibility * Improve filter layout and variable consistency
1 parent 47467ec commit f370264

File tree

13 files changed

+99
-20
lines changed

13 files changed

+99
-20
lines changed

airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,18 @@ paths:
20412041
type: string
20422042
default: id
20432043
title: Order By
2044+
- name: run_id_pattern
2045+
in: query
2046+
required: false
2047+
schema:
2048+
anyOf:
2049+
- type: string
2050+
- type: 'null'
2051+
description: "SQL LIKE expression \u2014 use `%` / `_` wildcards (e.g. `%customer_%`).\
2052+
\ Regular expressions are **not** supported."
2053+
title: Run Id Pattern
2054+
description: "SQL LIKE expression \u2014 use `%` / `_` wildcards (e.g. `%customer_%`).\
2055+
\ Regular expressions are **not** supported."
20442056
responses:
20452057
'200':
20462058
description: Successful Response

airflow-core/src/airflow/api_fastapi/core_api/routes/public/dag_run.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
Range,
4747
RangeFilter,
4848
SortParam,
49+
_SearchParam,
4950
datetime_range_filter_factory,
51+
search_param_factory,
5052
)
5153
from airflow.api_fastapi.common.router import AirflowRouter
5254
from airflow.api_fastapi.core_api.datamodels.assets import AssetEventCollectionResponse
@@ -334,6 +336,7 @@ def get_dag_runs(
334336
readable_dag_runs_filter: ReadableDagRunsFilterDep,
335337
session: SessionDep,
336338
dag_bag: DagBagDep,
339+
run_id_pattern: Annotated[_SearchParam, Depends(search_param_factory(DagRun.run_id, "run_id_pattern"))],
337340
) -> DAGRunCollectionResponse:
338341
"""
339342
Get all DAG Runs.
@@ -360,6 +363,7 @@ def get_dag_runs(
360363
state,
361364
run_type,
362365
readable_dag_runs_filter,
366+
run_id_pattern,
363367
],
364368
order_by=order_by,
365369
offset=offset,

airflow-core/src/airflow/ui/openapi-gen/queries/common.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export const UseDagRunServiceGetUpstreamAssetEventsKeyFn = ({ dagId, dagRunId }:
140140
export type DagRunServiceGetDagRunsDefaultResponse = Awaited<ReturnType<typeof DagRunService.getDagRuns>>;
141141
export type DagRunServiceGetDagRunsQueryResult<TData = DagRunServiceGetDagRunsDefaultResponse, TError = unknown> = UseQueryResult<TData, TError>;
142142
export const useDagRunServiceGetDagRunsKey = "DagRunServiceGetDagRuns";
143-
export const UseDagRunServiceGetDagRunsKeyFn = ({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
143+
export const UseDagRunServiceGetDagRunsKeyFn = ({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
144144
dagId: string;
145145
endDateGte?: string;
146146
endDateLte?: string;
@@ -151,13 +151,14 @@ export const UseDagRunServiceGetDagRunsKeyFn = ({ dagId, endDateGte, endDateLte,
151151
orderBy?: string;
152152
runAfterGte?: string;
153153
runAfterLte?: string;
154+
runIdPattern?: string;
154155
runType?: string[];
155156
startDateGte?: string;
156157
startDateLte?: string;
157158
state?: string[];
158159
updatedAtGte?: string;
159160
updatedAtLte?: string;
160-
}, queryKey?: Array<unknown>) => [useDagRunServiceGetDagRunsKey, ...(queryKey ?? [{ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }])];
161+
}, queryKey?: Array<unknown>) => [useDagRunServiceGetDagRunsKey, ...(queryKey ?? [{ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }])];
161162
export type DagSourceServiceGetDagSourceDefaultResponse = Awaited<ReturnType<typeof DagSourceService.getDagSource>>;
162163
export type DagSourceServiceGetDagSourceQueryResult<TData = DagSourceServiceGetDagSourceDefaultResponse, TError = unknown> = UseQueryResult<TData, TError>;
163164
export const useDagSourceServiceGetDagSourceKey = "DagSourceServiceGetDagSource";

airflow-core/src/airflow/ui/openapi-gen/queries/ensureQueryData.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ export const ensureUseDagRunServiceGetUpstreamAssetEventsData = (queryClient: Qu
272272
* @param data.runType
273273
* @param data.state
274274
* @param data.orderBy
275+
* @param data.runIdPattern SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
275276
* @returns DAGRunCollectionResponse Successful Response
276277
* @throws ApiError
277278
*/
278-
export const ensureUseDagRunServiceGetDagRunsData = (queryClient: QueryClient, { dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
279+
export const ensureUseDagRunServiceGetDagRunsData = (queryClient: QueryClient, { dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
279280
dagId: string;
280281
endDateGte?: string;
281282
endDateLte?: string;
@@ -286,13 +287,14 @@ export const ensureUseDagRunServiceGetDagRunsData = (queryClient: QueryClient, {
286287
orderBy?: string;
287288
runAfterGte?: string;
288289
runAfterLte?: string;
290+
runIdPattern?: string;
289291
runType?: string[];
290292
startDateGte?: string;
291293
startDateLte?: string;
292294
state?: string[];
293295
updatedAtGte?: string;
294296
updatedAtLte?: string;
295-
}) => queryClient.ensureQueryData({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) });
297+
}) => queryClient.ensureQueryData({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) });
296298
/**
297299
* Get Dag Source
298300
* Get source code using file token.

airflow-core/src/airflow/ui/openapi-gen/queries/prefetch.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ export const prefetchUseDagRunServiceGetUpstreamAssetEvents = (queryClient: Quer
272272
* @param data.runType
273273
* @param data.state
274274
* @param data.orderBy
275+
* @param data.runIdPattern SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
275276
* @returns DAGRunCollectionResponse Successful Response
276277
* @throws ApiError
277278
*/
278-
export const prefetchUseDagRunServiceGetDagRuns = (queryClient: QueryClient, { dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
279+
export const prefetchUseDagRunServiceGetDagRuns = (queryClient: QueryClient, { dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
279280
dagId: string;
280281
endDateGte?: string;
281282
endDateLte?: string;
@@ -286,13 +287,14 @@ export const prefetchUseDagRunServiceGetDagRuns = (queryClient: QueryClient, { d
286287
orderBy?: string;
287288
runAfterGte?: string;
288289
runAfterLte?: string;
290+
runIdPattern?: string;
289291
runType?: string[];
290292
startDateGte?: string;
291293
startDateLte?: string;
292294
state?: string[];
293295
updatedAtGte?: string;
294296
updatedAtLte?: string;
295-
}) => queryClient.prefetchQuery({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) });
297+
}) => queryClient.prefetchQuery({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) });
296298
/**
297299
* Get Dag Source
298300
* Get source code using file token.

airflow-core/src/airflow/ui/openapi-gen/queries/queries.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ export const useDagRunServiceGetUpstreamAssetEvents = <TData = Common.DagRunServ
272272
* @param data.runType
273273
* @param data.state
274274
* @param data.orderBy
275+
* @param data.runIdPattern SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
275276
* @returns DAGRunCollectionResponse Successful Response
276277
* @throws ApiError
277278
*/
278-
export const useDagRunServiceGetDagRuns = <TData = Common.DagRunServiceGetDagRunsDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
279+
export const useDagRunServiceGetDagRuns = <TData = Common.DagRunServiceGetDagRunsDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
279280
dagId: string;
280281
endDateGte?: string;
281282
endDateLte?: string;
@@ -286,13 +287,14 @@ export const useDagRunServiceGetDagRuns = <TData = Common.DagRunServiceGetDagRun
286287
orderBy?: string;
287288
runAfterGte?: string;
288289
runAfterLte?: string;
290+
runIdPattern?: string;
289291
runType?: string[];
290292
startDateGte?: string;
291293
startDateLte?: string;
292294
state?: string[];
293295
updatedAtGte?: string;
294296
updatedAtLte?: string;
295-
}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn">) => useQuery<TData, TError>({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }, queryKey), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) as TData, ...options });
297+
}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn">) => useQuery<TData, TError>({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }, queryKey), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) as TData, ...options });
296298
/**
297299
* Get Dag Source
298300
* Get source code using file token.

airflow-core/src/airflow/ui/openapi-gen/queries/suspense.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ export const useDagRunServiceGetUpstreamAssetEventsSuspense = <TData = Common.Da
272272
* @param data.runType
273273
* @param data.state
274274
* @param data.orderBy
275+
* @param data.runIdPattern SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
275276
* @returns DAGRunCollectionResponse Successful Response
276277
* @throws ApiError
277278
*/
278-
export const useDagRunServiceGetDagRunsSuspense = <TData = Common.DagRunServiceGetDagRunsDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
279+
export const useDagRunServiceGetDagRunsSuspense = <TData = Common.DagRunServiceGetDagRunsDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }: {
279280
dagId: string;
280281
endDateGte?: string;
281282
endDateLte?: string;
@@ -286,13 +287,14 @@ export const useDagRunServiceGetDagRunsSuspense = <TData = Common.DagRunServiceG
286287
orderBy?: string;
287288
runAfterGte?: string;
288289
runAfterLte?: string;
290+
runIdPattern?: string;
289291
runType?: string[];
290292
startDateGte?: string;
291293
startDateLte?: string;
292294
state?: string[];
293295
updatedAtGte?: string;
294296
updatedAtLte?: string;
295-
}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn">) => useSuspenseQuery<TData, TError>({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }, queryKey), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) as TData, ...options });
297+
}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn">) => useSuspenseQuery<TData, TError>({ queryKey: Common.UseDagRunServiceGetDagRunsKeyFn({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }, queryKey), queryFn: () => DagRunService.getDagRuns({ dagId, endDateGte, endDateLte, limit, logicalDateGte, logicalDateLte, offset, orderBy, runAfterGte, runAfterLte, runIdPattern, runType, startDateGte, startDateLte, state, updatedAtGte, updatedAtLte }) as TData, ...options });
296298
/**
297299
* Get Dag Source
298300
* Get source code using file token.

airflow-core/src/airflow/ui/openapi-gen/requests/services.gen.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,7 @@ export class DagRunService {
983983
* @param data.runType
984984
* @param data.state
985985
* @param data.orderBy
986+
* @param data.runIdPattern SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
986987
* @returns DAGRunCollectionResponse Successful Response
987988
* @throws ApiError
988989
*/
@@ -1008,7 +1009,8 @@ export class DagRunService {
10081009
updated_at_lte: data.updatedAtLte,
10091010
run_type: data.runType,
10101011
state: data.state,
1011-
order_by: data.orderBy
1012+
order_by: data.orderBy,
1013+
run_id_pattern: data.runIdPattern
10121014
},
10131015
errors: {
10141016
401: 'Unauthorized',

airflow-core/src/airflow/ui/openapi-gen/requests/types.gen.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,6 +2195,10 @@ export type GetDagRunsData = {
21952195
orderBy?: string;
21962196
runAfterGte?: string | null;
21972197
runAfterLte?: string | null;
2198+
/**
2199+
* SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
2200+
*/
2201+
runIdPattern?: string | null;
21982202
runType?: Array<(string)>;
21992203
startDateGte?: string | null;
22002204
startDateLte?: string | null;

airflow-core/src/airflow/ui/public/i18n/locales/en/dags.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"active": "Active",
2020
"all": "All",
2121
"paused": "Paused"
22-
}
22+
},
23+
"runIdPatternFilter": "Search Dag Runs"
2324
},
2425
"ownerLink": "Owner link for {{owner}}",
2526
"runAndTaskActions": {

0 commit comments

Comments
 (0)