You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2022/10/18 13:10:20 UTC

[airflow] 04/41: Revert "No grid auto-refresh for backfill dag runs (#25042)" (#26463)

This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-4-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 8e836db4855db681f7539733f6b08fb190d899ed
Author: Tim Sanders <go...@gmail.com>
AuthorDate: Wed Sep 21 12:35:01 2022 -0500

    Revert "No grid auto-refresh for backfill dag runs (#25042)" (#26463)
    
    * Revert "No grid auto-refresh for backfill dag runs (#25042)"
    
    This reverts commit de6938e173773d88bd741e43c7b0aa16d8a1a167.
    
    * Fix Grid unit test
    
    (cherry picked from commit d0b3d59c958f98d3b9856d661c8479284e70bb39)
---
 airflow/www/static/js/api/useGridData.test.ts | 64 +++------------------------
 airflow/www/static/js/api/useGridData.ts      |  2 +-
 2 files changed, 7 insertions(+), 59 deletions(-)

diff --git a/airflow/www/static/js/api/useGridData.test.ts b/airflow/www/static/js/api/useGridData.test.ts
index c5a0e6c9de..43d581f000 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,
@@ -35,75 +36,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 f9a5737c5d..737167552c 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();