How do I trigger all upstream_failed task to “retry” after their parents state changed to success in...












1














I have a simple example showing a DAG with two levels. When running, this dag fails because artificial bug, there is one failed task and one that that is upstream_fail.



bug = True 

def process1(param):
print("process 1 running {}".format(param))
if bug and (param == 2):
raise Exception("failure!!")


def process2(param):
print("process 2 running {}".format(param))


with dag:
for i in range(10):
task1 = PythonOperator(
task_id="process_1_{}".format(i),
python_callable=process1,
op_kwargs={'param': i}
)
task2 = PythonOperator(
task_id="process_2_{}".format(i),
python_callable=process2,
op_kwargs={'param': i},
trigger_rule=TriggerRule.ALL_SUCCESS,
retries=2
)
task1 >> task2


Now lets assume I fixed the bug (bug = False) and tried to clear all failed task:



airflow clear -s 2001 -e 2019 --only_failed test_resubmit


This command clears the task test_resubmit.process_1_2 and it will run successfully, however its downstream (i.e. test_resubmit.process_2_2) is still in the upstream_failed state. How do I trigger all upstream_failed task to "retry" after their parents state changed to success?










share|improve this question



























    1














    I have a simple example showing a DAG with two levels. When running, this dag fails because artificial bug, there is one failed task and one that that is upstream_fail.



    bug = True 

    def process1(param):
    print("process 1 running {}".format(param))
    if bug and (param == 2):
    raise Exception("failure!!")


    def process2(param):
    print("process 2 running {}".format(param))


    with dag:
    for i in range(10):
    task1 = PythonOperator(
    task_id="process_1_{}".format(i),
    python_callable=process1,
    op_kwargs={'param': i}
    )
    task2 = PythonOperator(
    task_id="process_2_{}".format(i),
    python_callable=process2,
    op_kwargs={'param': i},
    trigger_rule=TriggerRule.ALL_SUCCESS,
    retries=2
    )
    task1 >> task2


    Now lets assume I fixed the bug (bug = False) and tried to clear all failed task:



    airflow clear -s 2001 -e 2019 --only_failed test_resubmit


    This command clears the task test_resubmit.process_1_2 and it will run successfully, however its downstream (i.e. test_resubmit.process_2_2) is still in the upstream_failed state. How do I trigger all upstream_failed task to "retry" after their parents state changed to success?










    share|improve this question

























      1












      1








      1







      I have a simple example showing a DAG with two levels. When running, this dag fails because artificial bug, there is one failed task and one that that is upstream_fail.



      bug = True 

      def process1(param):
      print("process 1 running {}".format(param))
      if bug and (param == 2):
      raise Exception("failure!!")


      def process2(param):
      print("process 2 running {}".format(param))


      with dag:
      for i in range(10):
      task1 = PythonOperator(
      task_id="process_1_{}".format(i),
      python_callable=process1,
      op_kwargs={'param': i}
      )
      task2 = PythonOperator(
      task_id="process_2_{}".format(i),
      python_callable=process2,
      op_kwargs={'param': i},
      trigger_rule=TriggerRule.ALL_SUCCESS,
      retries=2
      )
      task1 >> task2


      Now lets assume I fixed the bug (bug = False) and tried to clear all failed task:



      airflow clear -s 2001 -e 2019 --only_failed test_resubmit


      This command clears the task test_resubmit.process_1_2 and it will run successfully, however its downstream (i.e. test_resubmit.process_2_2) is still in the upstream_failed state. How do I trigger all upstream_failed task to "retry" after their parents state changed to success?










      share|improve this question













      I have a simple example showing a DAG with two levels. When running, this dag fails because artificial bug, there is one failed task and one that that is upstream_fail.



      bug = True 

      def process1(param):
      print("process 1 running {}".format(param))
      if bug and (param == 2):
      raise Exception("failure!!")


      def process2(param):
      print("process 2 running {}".format(param))


      with dag:
      for i in range(10):
      task1 = PythonOperator(
      task_id="process_1_{}".format(i),
      python_callable=process1,
      op_kwargs={'param': i}
      )
      task2 = PythonOperator(
      task_id="process_2_{}".format(i),
      python_callable=process2,
      op_kwargs={'param': i},
      trigger_rule=TriggerRule.ALL_SUCCESS,
      retries=2
      )
      task1 >> task2


      Now lets assume I fixed the bug (bug = False) and tried to clear all failed task:



      airflow clear -s 2001 -e 2019 --only_failed test_resubmit


      This command clears the task test_resubmit.process_1_2 and it will run successfully, however its downstream (i.e. test_resubmit.process_2_2) is still in the upstream_failed state. How do I trigger all upstream_failed task to "retry" after their parents state changed to success?







      airflow






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 27 '18 at 16:33









      motam79

      869923




      869923
























          1 Answer
          1






          active

          oldest

          votes


















          0














          The upstream_failed state is an end state, so it will not retry even if its dependencies are now satisfied (unlike up_for_retry). You'll want to pass --downstream so that tasks downstream of the failed tasks are also cleared.



          See all options in https://airflow.readthedocs.io/en/stable/cli.html#clear.






          share|improve this answer





















          • I tried --downstream, it does not work. It does not "clear" the downstream task of a failed task. I had to manually select all downstream task and clear them.
            – motam79
            Dec 28 '18 at 1:29











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53948092%2fhow-do-i-trigger-all-upstream-failed-task-to-retry-after-their-parents-state-c%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          The upstream_failed state is an end state, so it will not retry even if its dependencies are now satisfied (unlike up_for_retry). You'll want to pass --downstream so that tasks downstream of the failed tasks are also cleared.



          See all options in https://airflow.readthedocs.io/en/stable/cli.html#clear.






          share|improve this answer





















          • I tried --downstream, it does not work. It does not "clear" the downstream task of a failed task. I had to manually select all downstream task and clear them.
            – motam79
            Dec 28 '18 at 1:29
















          0














          The upstream_failed state is an end state, so it will not retry even if its dependencies are now satisfied (unlike up_for_retry). You'll want to pass --downstream so that tasks downstream of the failed tasks are also cleared.



          See all options in https://airflow.readthedocs.io/en/stable/cli.html#clear.






          share|improve this answer





















          • I tried --downstream, it does not work. It does not "clear" the downstream task of a failed task. I had to manually select all downstream task and clear them.
            – motam79
            Dec 28 '18 at 1:29














          0












          0








          0






          The upstream_failed state is an end state, so it will not retry even if its dependencies are now satisfied (unlike up_for_retry). You'll want to pass --downstream so that tasks downstream of the failed tasks are also cleared.



          See all options in https://airflow.readthedocs.io/en/stable/cli.html#clear.






          share|improve this answer












          The upstream_failed state is an end state, so it will not retry even if its dependencies are now satisfied (unlike up_for_retry). You'll want to pass --downstream so that tasks downstream of the failed tasks are also cleared.



          See all options in https://airflow.readthedocs.io/en/stable/cli.html#clear.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 27 '18 at 17:57









          Daniel Huang

          1,844914




          1,844914












          • I tried --downstream, it does not work. It does not "clear" the downstream task of a failed task. I had to manually select all downstream task and clear them.
            – motam79
            Dec 28 '18 at 1:29


















          • I tried --downstream, it does not work. It does not "clear" the downstream task of a failed task. I had to manually select all downstream task and clear them.
            – motam79
            Dec 28 '18 at 1:29
















          I tried --downstream, it does not work. It does not "clear" the downstream task of a failed task. I had to manually select all downstream task and clear them.
          – motam79
          Dec 28 '18 at 1:29




          I tried --downstream, it does not work. It does not "clear" the downstream task of a failed task. I had to manually select all downstream task and clear them.
          – motam79
          Dec 28 '18 at 1:29


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53948092%2fhow-do-i-trigger-all-upstream-failed-task-to-retry-after-their-parents-state-c%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Monofisismo

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas