From ae819134c83afe4da8bf374df4f04d9f921d3d0b Mon Sep 17 00:00:00 2001 From: DC Date: Fri, 7 Dec 2018 20:39:14 +0530 Subject: [PATCH 1/2] get dag run status by dag_id and run_id --- blueprints/airflow_api.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/blueprints/airflow_api.py b/blueprints/airflow_api.py index 2d1f0ab..470d4d4 100644 --- a/blueprints/airflow_api.py +++ b/blueprints/airflow_api.py @@ -284,4 +284,24 @@ def get_dag_run(dag_run_id): session.close() + return ApiResponse.success({'dag_run': format_dag_run(dag_run)}) + +# When using a subdagoperator if a downstream task fails this method still returns the status of the run_id as running +# However in the dashboard the main dag will show that as a failure. Adding the dag_name will resolve this + +@airflow_api_blueprint.route('/dags/dag_runs/', methods=['GET']) +def get_dag_run(): + session = settings.Session() + run_id=request.args.get('run_id') + dag_id=request.args.get('dag_id') + + runs = DagRun.find(dag_id=dag_id , run_id=run_id, session=session) + + if len(runs) == 0: + return ApiResponse.not_found('Dag run not found') + + dag_run = runs[0] + + session.close() + return ApiResponse.success({'dag_run': format_dag_run(dag_run)}) \ No newline at end of file From f2b0dd47b707e544c32315ba7d00dd4c5b51a7bb Mon Sep 17 00:00:00 2001 From: dwai1714 Date: Fri, 7 Dec 2018 22:29:27 +0530 Subject: [PATCH 2/2] func --- blueprints/airflow_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blueprints/airflow_api.py b/blueprints/airflow_api.py index 470d4d4..efd16ed 100644 --- a/blueprints/airflow_api.py +++ b/blueprints/airflow_api.py @@ -290,7 +290,7 @@ def get_dag_run(dag_run_id): # However in the dashboard the main dag will show that as a failure. Adding the dag_name will resolve this @airflow_api_blueprint.route('/dags/dag_runs/', methods=['GET']) -def get_dag_run(): +def get_dag_run_with_dag(): session = settings.Session() run_id=request.args.get('run_id') dag_id=request.args.get('dag_id')