You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/06/10 10:20:42 UTC

[GitHub] [airflow] ChristianYeah opened a new issue #9209: mark dag_run as failed internally, eg, in one of tasks

ChristianYeah opened a new issue #9209:
URL: https://github.com/apache/airflow/issues/9209


   airflow: 1.10.10
   
   I searched google for marking a single dag run as failed if some task logic doesn't meet with a particular condition.
   
   for example, if task A requests the URL, the expected result should be error_code == 0.
   Now I manually do something like ```print(1/0)``` to raise the exception if I get error_code 1.
   
   Is that possible to manually mark the dag_run as failed internally? 
   
   Thank you very much


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [airflow] barmanand commented on issue #9209: mark dag_run as failed internally, eg, in one of the internal tasks

Posted by GitBox <gi...@apache.org>.
barmanand commented on issue #9209:
URL: https://github.com/apache/airflow/issues/9209#issuecomment-648039812


   yes @ChristianYeah You can raise AirflowException and it will fail the task 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [airflow] ChristianYeah commented on issue #9209: mark dag_run as failed internally, eg, in one of the internal tasks

Posted by GitBox <gi...@apache.org>.
ChristianYeah commented on issue #9209:
URL: https://github.com/apache/airflow/issues/9209#issuecomment-648054894


   @barmanand thank you


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [airflow] ChristianYeah commented on issue #9209: mark dag_run as failed internally, eg, in one of the internal tasks

Posted by GitBox <gi...@apache.org>.
ChristianYeah commented on issue #9209:
URL: https://github.com/apache/airflow/issues/9209#issuecomment-648032574


   > can we explain the requirement with clear example?
   
   ```
   import airflow
   from airflow import DAG
   from airflow.operators.python_operator import PythonOperator
   import requests
   
   
   default_args = {
       'owner': 'airflow',
   }
   
   dag = DAG(
       dag_id='test_max_active_runs',
       default_args=default_args,
       schedule_interval=None,
       start_date=airflow.utils.dates.days_ago(1),
       max_active_runs=1,
       catchup=False
   )
   
   
   def example_func():
       data = requests.get("some url").json()
       if data.get('code', -1) == 0:
           #  no error in the response
           #  further process
           #  eg.
           print(data.get('results', []))
       else:
           #  error in response
           print(data.get('message', ''))
           # mark the task as failed here
           # something like below
           fail_this_task()
   
   
   example = PythonOperator(
       task_id='example',
       python_callable=example_func,
       dag=dag,
   )
   
   ```
   
   is that possible I can fail the task dynamically if I get the response of "code" except 0?
   
   @barmanand , thank you very much


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [airflow] ChristianYeah closed issue #9209: mark dag_run as failed internally, eg, in one of the internal tasks

Posted by GitBox <gi...@apache.org>.
ChristianYeah closed issue #9209:
URL: https://github.com/apache/airflow/issues/9209


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [airflow] barmanand commented on issue #9209: mark dag_run as failed internally, eg, in one of the internal tasks

Posted by GitBox <gi...@apache.org>.
barmanand commented on issue #9209:
URL: https://github.com/apache/airflow/issues/9209#issuecomment-646713657


   can we explain the requirement with clear example?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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