guptakumartanuj 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_r285892131
##########
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. ti_fails will always be in sorted order because of the nature of
task_fail table having auto increment key.
2. try_count is always reset as 1 in the starting of the for loop of
ti_fails. But yeah thanks for catching this. I have to reset it once new failed
task instance comes into the picture.
3. gantt_bar_items appended against the tis metadata are having the state as
success or running or final fail from task_instance table so having the
try_number for the same only. It doesn't capture the all the failed instances.
In case of failed tasks, entries go into task_fail table and we can't get the
try number from there directly hence I am incrementing the try_count and
appending the same against ti_fails metadata because of the nature of task_fail
table.
----------------------------------------------------------------
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