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_r363045256
 
 

 ##########
 File path: airflow/cli/commands/task_command.py
 ##########
 @@ -213,6 +215,38 @@ 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"""
+    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.")
+    formatted_rows = []
+    for ti in tis:
+        formatted_rows.append((ti.dag_id,
+                               ti.execution_date,
+                               ti.task_id,
+                               ti.state,
+                               ti.start_date,
+                               ti.end_date))
+
+    print(
+        "\n%s" %
+        tabulate(
+            formatted_rows, [
+                'dag', 'exec_date', 'task', 'state', 'start_date', 
'end_date'], tablefmt="fancy_grid"))
 
 Review comment:
   ```suggestion
                   'dag', 'exec_date', 'task', 'state', 'start_date', 
'end_date'], tablefmt=args.output))
   ```
   Can you add support for other formats?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to