From 25fa2c4ce6cf54be3958efac2395858a17d5281b Mon Sep 17 00:00:00 2001 From: Gollum999 Date: Sun, 18 Sep 2022 14:23:17 -0500 Subject: [PATCH 1/2] Revert "No grid auto-refresh for backfill dag runs (#25042)" This reverts commit de6938e173773d88bd741e43c7b0aa16d8a1a167. --- airflow/www/static/js/api/useGridData.test.ts | 63 ++----------------- airflow/www/static/js/api/useGridData.ts | 2 +- 2 files changed, 6 insertions(+), 59 deletions(-) diff --git a/airflow/www/static/js/api/useGridData.test.ts b/airflow/www/static/js/api/useGridData.test.ts index c5a0e6c9de515..6e7c5c2bf7bde 100644 --- a/airflow/www/static/js/api/useGridData.test.ts +++ b/airflow/www/static/js/api/useGridData.test.ts @@ -35,75 +35,22 @@ const commonDagRunParams = { describe('Test areActiveRuns()', () => { test('Correctly detects active runs', () => { const runs: DagRun[] = [ - { runType: 'scheduled', state: 'success', ...commonDagRunParams }, - { runType: 'manual', state: 'queued', ...commonDagRunParams }, + { state: 'success', ...commonDagRunParams }, + { state: 'queued', ...commonDagRunParams }, ]; expect(areActiveRuns(runs)).toBe(true); }); test('Returns false when all runs are resolved', () => { const runs: DagRun[] = [ - { runType: 'scheduled', state: 'success', ...commonDagRunParams }, - { runType: 'manual', state: 'failed', ...commonDagRunParams }, - { runType: 'manual', state: 'failed', ...commonDagRunParams }, + { state: 'success', ...commonDagRunParams }, + { state: 'failed', ...commonDagRunParams }, + { state: 'failed', ...commonDagRunParams }, ]; const result = areActiveRuns(runs); expect(result).toBe(false); }); - test('Returns false when filtering runs runtype ["backfill"]', () => { - const runs: DagRun[] = [ - { runType: 'scheduled', state: 'success', ...commonDagRunParams }, - { runType: 'manual', state: 'failed', ...commonDagRunParams }, - { runType: 'backfill', state: 'failed', ...commonDagRunParams }, - ]; - const result = areActiveRuns(runs); - expect(result).toBe(false); - }); - - test('Returns false when filtering runs runtype ["backfill"] and state ["queued"]', () => { - const runs: DagRun[] = [ - { runType: 'scheduled', state: 'success', ...commonDagRunParams }, - { runType: 'manual', state: 'failed', ...commonDagRunParams }, - { runType: 'backfill', state: 'queued', ...commonDagRunParams }, - ]; - const result = areActiveRuns(runs); - expect(result).toBe(false); - }); - - [ - { - runType: 'manual', state: 'queued', expectedResult: true, - }, - { - runType: 'manual', state: 'running', expectedResult: true, - }, - { - runType: 'scheduled', state: 'queued', expectedResult: true, - }, - { - runType: 'scheduled', state: 'running', expectedResult: true, - }, - { - runType: 'dataset_triggered', state: 'queued', expectedResult: true, - }, - { - runType: 'dataset_triggered', state: 'running', expectedResult: true, - }, - { - runType: 'backfill', state: 'queued', expectedResult: false, - }, - { - runType: 'backfill', state: 'running', expectedResult: false, - }, - ].forEach(({ state, runType, expectedResult }) => { - test(`Returns ${expectedResult} when filtering runs with runtype ["${runType}"] and state ["${state}"]`, () => { - const runs: DagRun[] = [{ runType, state, ...commonDagRunParams } as DagRun]; - const result = areActiveRuns(runs); - expect(result).toBe(expectedResult); - }); - }); - test('Returns false when there are no runs', () => { const result = areActiveRuns(); expect(result).toBe(false); diff --git a/airflow/www/static/js/api/useGridData.ts b/airflow/www/static/js/api/useGridData.ts index 8af05b5420b06..d63e02d3c7942 100644 --- a/airflow/www/static/js/api/useGridData.ts +++ b/airflow/www/static/js/api/useGridData.ts @@ -57,7 +57,7 @@ const formatOrdering = (data: GridData) => ({ ordering: data.ordering.map((o: string) => camelCase(o)) as RunOrdering, }); -export const areActiveRuns = (runs: DagRun[] = []) => runs.filter((run) => ['manual', 'scheduled', 'dataset_triggered'].includes(run.runType)).filter((run) => ['queued', 'running'].includes(run.state)).length > 0; +export const areActiveRuns = (runs: DagRun[] = []) => runs.filter((run) => ['queued', 'running'].includes(run.state)).length > 0; const useGridData = () => { const { isRefreshOn, stopRefresh } = useAutoRefresh(); From 25beb70371a3f3a5692582a4e1815d328987c4c3 Mon Sep 17 00:00:00 2001 From: Gollum999 Date: Sun, 18 Sep 2022 15:52:30 -0500 Subject: [PATCH 2/2] Fix Grid unit test --- airflow/www/static/js/api/useGridData.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/airflow/www/static/js/api/useGridData.test.ts b/airflow/www/static/js/api/useGridData.test.ts index 6e7c5c2bf7bde..43d581f0006d0 100644 --- a/airflow/www/static/js/api/useGridData.test.ts +++ b/airflow/www/static/js/api/useGridData.test.ts @@ -27,6 +27,7 @@ const commonDagRunParams = { executionDate: '2022-01-01T10:00+00:00', dataIntervalStart: '2022-01-01T05:00+00:00', dataIntervalEnd: '2022-01-01T10:00+00:00', + runType: 'scheduled' as DagRun['runType'], startDate: null, endDate: null, lastSchedulingDecision: null,