airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] ubermen closed pull request #3667: [AIRFLOW-1298] Add clear option 'only_failed_or_upstream_failed'
Date Mon, 06 Aug 2018 06:28:40 GMT
ubermen closed pull request #3667: [AIRFLOW-1298] Add clear option 'only_failed_or_upstream_failed'
URL: https://github.com/apache/incubator-airflow/pull/3667
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/bin/cli.py b/airflow/bin/cli.py
index b56e325327..8e329bd074 100644
--- a/airflow/bin/cli.py
+++ b/airflow/bin/cli.py
@@ -627,6 +627,7 @@ def clear(args):
         start_date=args.start_date,
         end_date=args.end_date,
         only_failed=args.only_failed,
+        only_failed_or_upstream_failed=args.only_failed_or_upstream_failed,
         only_running=args.only_running,
         confirm_prompt=not args.no_confirm,
         include_subdags=not args.exclude_subdags)
@@ -1399,6 +1400,9 @@ class CLIFactory(object):
             ("-u", "--upstream"), "Include upstream tasks", "store_true"),
         'only_failed': Arg(
             ("-f", "--only_failed"), "Only failed jobs", "store_true"),
+        'only_failed_or_upstream_failed': Arg(
+            ("-p", "--only_failed_or_upstream_failed"),
+            "Only failed or upstream_failed jobs", "store_true"),
         'only_running': Arg(
             ("-r", "--only_running"), "Only running jobs", "store_true"),
         'downstream': Arg(
@@ -1728,6 +1732,7 @@ class CLIFactory(object):
             'args': (
                 'dag_id', 'task_regex', 'start_date', 'end_date', 'subdir',
                 'upstream', 'downstream', 'no_confirm', 'only_failed',
+                'only_failed_or_upstream_failed',
                 'only_running', 'exclude_subdags', 'dag_regex'),
         }, {
             'func': pause,
diff --git a/airflow/models.py b/airflow/models.py
index b789fd1732..797ff69578 100755
--- a/airflow/models.py
+++ b/airflow/models.py
@@ -3751,6 +3751,7 @@ def set_dag_runs_state(
     def clear(
             self, start_date=None, end_date=None,
             only_failed=False,
+            only_failed_or_upstream_failed=False,
             only_running=False,
             confirm_prompt=False,
             include_subdags=True,
@@ -3783,6 +3784,9 @@ def clear(
             tis = tis.filter(TI.execution_date <= end_date)
         if only_failed:
             tis = tis.filter(TI.state == State.FAILED)
+        if only_failed_or_upstream_failed:
+            tis = tis.filter(or_(TI.state == State.FAILED,
+                                 TI.state == State.UPSTREAM_FAILED))
         if only_running:
             tis = tis.filter(TI.state == State.RUNNING)
 
@@ -3826,6 +3830,7 @@ def clear_dags(
             start_date=None,
             end_date=None,
             only_failed=False,
+            only_failed_or_upstream_failed=False,
             only_running=False,
             confirm_prompt=False,
             include_subdags=True,
@@ -3838,6 +3843,7 @@ def clear_dags(
                 start_date=start_date,
                 end_date=end_date,
                 only_failed=only_failed,
+                only_failed_or_upstream_failed=only_failed_or_upstream_failed,
                 only_running=only_running,
                 confirm_prompt=False,
                 include_subdags=include_subdags,
@@ -3866,6 +3872,7 @@ def clear_dags(
                 dag.clear(start_date=start_date,
                           end_date=end_date,
                           only_failed=only_failed,
+                          only_failed_or_upstream_failed=only_failed_or_upstream_failed,
                           only_running=only_running,
                           confirm_prompt=False,
                           include_subdags=include_subdags,


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message