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/01/02 01:41:25 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #6993: [AIRFLOW-4502] new cli command - task_states_for_dag_run

mik-laj commented on a change in pull request #6993: [AIRFLOW-4502] new cli command - task_states_for_dag_run
URL: https://github.com/apache/airflow/pull/6993#discussion_r362355856
 
 

 ##########
 File path: airflow/cli/commands/task_command.py
 ##########
 @@ -213,6 +213,29 @@ def task_list(args, dag=None):
         print("\n".join(sorted(tasks)))
 
 
+@cli_utils.action_logging
+def task_states_for_dag_run(args):
+    """Get the status of all task instances in a dag run"""
+    if not args.dag_id or not args.execution_date:
+        raise AirflowException("dag_id and execution_date are mandatory.")
+    session = settings.Session()
+    tis = session.query(
+        TaskInstance.dag_id,
+        TaskInstance.execution_date,
+        TaskInstance.task_id,
+        TaskInstance.state,
+        TaskInstance.start_date,
+        TaskInstance.end_date).filter(
+        TaskInstance.dag_id == args.dag_id,
+        TaskInstance.execution_date == args.execution_date).all()
+    session.close()
+    if len(tis) == 0:
+        raise AirflowException("dag run does not exist.")
+    for ti in tis:
+        print("dag={0}, exec_date={1}, task={2}, state={3}, start_date={4}, end_date={5}".format(
 
 Review comment:
   Can you use tabulate?  All CLI lists should use it to enable data display in various formats, e.g. CSV.
   Referencec: 
   https://github.com/apache/airflow/blob/master/airflow/cli/commands/pool_command.py#L31-L33

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