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 2022/02/23 21:58:22 UTC

[GitHub] [airflow] bbovenzi commented on a change in pull request #21740: Make Grid and and Graph view work with task mapping

bbovenzi commented on a change in pull request #21740:
URL: https://github.com/apache/airflow/pull/21740#discussion_r813359640



##########
File path: airflow/www/utils.py
##########
@@ -53,10 +56,82 @@ def datetime_to_string(value: Optional[DateTime]) -> Optional[str]:
     return value.isoformat()
 
 
-def encode_ti(task_instance: Optional[models.TaskInstance]) -> Optional[Dict[str, Any]]:
+def get_mapped_instances(task_instance, session):
+    return (
+        session.query(TaskInstance)
+        .filter(
+            TaskInstance.dag_id == task_instance.dag_id,
+            TaskInstance.run_id == task_instance.run_id,
+            TaskInstance.task_id == task_instance.task_id,
+            TaskInstance.map_index >= 0,
+        )
+        .all()
+    )
+
+
+def get_instance_with_map(task_instance, session):
+    if task_instance.map_index == -1:
+        return alchemy_to_dict(task_instance)
+    mapped_instances = get_mapped_instances(task_instance, session)
+    return get_mapped_summary(task_instance, mapped_instances)
+
+
+def get_mapped_summary(parent_instance, task_instances):
+    priority = [
+        'failed',
+        'upstream_failed',
+        'up_for_retry',
+        'up_for_reschedule',
+        'queued',
+        'scheduled',
+        'deferred',
+        'sensing',
+        'running',
+        'shutdown',
+        'restarting',
+        'removed',
+        'no_status',
+        'success',
+        'skipped',
+    ]

Review comment:
       Updated.




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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org