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/03/13 03:43:06 UTC

[GitHub] [airflow] zhongjiajie commented on a change in pull request #7709: [AIRFLOW-7053] Fix success/failed error in graph without dagrun

zhongjiajie commented on a change in pull request #7709: [AIRFLOW-7053] Fix success/failed error in graph without dagrun
URL: https://github.com/apache/airflow/pull/7709#discussion_r392015987
 
 

 ##########
 File path: airflow/www/views.py
 ##########
 @@ -1258,15 +1258,12 @@ def _mark_task_instance_state(self, dag_id, task_id, origin, execution_date,
         task = dag.get_task(task_id)
         task.dag = dag
 
-        execution_date = timezone.parse(execution_date)
-
-        if not dag:
-            flash("Cannot find DAG: {}".format(dag_id))
 
 Review comment:
   Remove check dag and check task(in line 1267) due to when I add test to cover it I realize those two condition never reach with `task = dag.get_task(task_id)` in line 1258.
   
   for dag check, I add test
   ```py
       def test_failed_invalid_dag(self):
           dag_id = "invalid"
           form = dict(
               task_id="run_this_last",
               dag_id=dag_id,
               execution_date=self.EXAMPLE_DAG_DEFAULT_DATE,
               upstream="false",
               downstream="false",
               future="false",
               past="false",
               origin="/graph?dag_id=example_bash_operator",
           )
           resp = self.client.post("failed", data=form, follow_redirects=True)
           self.check_content_in_response(f"Cannot find DAG: {dag_id}", resp)
   ```
   And test failed due to `NoneType without function get_task`.
   
   For task check, I add test
   ```py
       def test_success_invalid_task(self):
           task_id = "invalid"
           dag_id = "example_bash_operator"
           form = dict(
               task_id=task_id,
               dag_id=dag_id,
               execution_date=self.EXAMPLE_DAG_DEFAULT_DATE,
               upstream="false",
               downstream="false",
               future="false",
               past="false",
               origin="/graph?dag_id=example_bash_operator",
           )
           resp = self.client.post("success", data=form, follow_redirects=True)
           self.check_content_in_response(f"Cannot find task {task_id} in DAG {dag_id}", resp)
   ```
   The test also failed due to `airflow.exceptions.TaskNotFound: Task invalid not found`
   
   So I decide to remove them.

----------------------------------------------------------------
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


With regards,
Apache Git Services