KevinYang21 commented on a change in pull request #5037: [AIRFLOW-4237]
Including Try Number of Task in Gantt Chart
URL: https://github.com/apache/airflow/pull/5037#discussion_r287140378
##########
File path: airflow/www/views.py
##########
@@ -1738,10 +1738,21 @@ def gantt(self, session=None):
gantt_bar_items = []
for ti in tis:
end_date = ti.end_date or timezone.utcnow()
- gantt_bar_items.append((ti.task_id, ti.start_date, end_date,
ti.state))
+ try_count = ti.try_number
+ if ti.state == State.FAILED or ti.state == State.SUCCESS:
+ try_count = ti.try_number - 1
+ gantt_bar_items.append((ti.task_id, ti.start_date, end_date,
ti.state, try_count))
+
+ tf_count = 0
+ prev_task_id = ""
for tf in ti_fails:
end_date = tf.end_date or timezone.utcnow()
- gantt_bar_items.append((tf.task_id, tf.start_date, end_date,
State.FAILED))
+ try_count = 1
+ if tf_count != 0 and tf.task_id == prev_task_id:
+ try_count = try_count + 1
Review comment:
1. I don't think having auto increment key has anything to do with the order
of data returned. A quick search gave me
[this](https://dba.stackexchange.com/questions/5774/why-is-ssms-inserting-new-rows-at-the-top-of-a-table-not-the-bottom/5775#5775https://dba.stackexchange.com/questions/5774/why-is-ssms-inserting-new-rows-at-the-top-of-a-table-not-the-bottom/5775#5775).
3. Assuming appending twice will not create two row for the same task
instance in the graph( please confirm this), we are showing total try count
only if the task instance is in FAILED state. This can be quite confusing. We
need to probably revisit and decide what exactly we want to display and at
least make sure it is consistent between task instances in different states.
----------------------------------------------------------------
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