You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by as...@apache.org on 2020/06/27 13:40:16 UTC
[airflow] branch master updated: show correct duration on graph
view for running task (#8311) (#8675)
This is an automated email from the ASF dual-hosted git repository.
ash pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new 118ea2f show correct duration on graph view for running task (#8311) (#8675)
118ea2f is described below
commit 118ea2fbfeefd9e614551c1e141502a69b93eb4e
Author: YI FU <fu...@users.noreply.github.com>
AuthorDate: Sat Jun 27 15:39:33 2020 +0200
show correct duration on graph view for running task (#8311) (#8675)
* show correct duration on graph view for running task (#8311)
* fix invalid end date (#8311)
* Update airflow/www/static/js/task-instances.js
Co-authored-by: Ash Berlin-Taylor <as...@firemirror.com>
Co-authored-by: Ash Berlin-Taylor <as...@firemirror.com>
---
airflow/www/static/js/task-instances.js | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/airflow/www/static/js/task-instances.js b/airflow/www/static/js/task-instances.js
index 8b25c4f..d650a2f 100644
--- a/airflow/www/static/js/task-instances.js
+++ b/airflow/www/static/js/task-instances.js
@@ -20,12 +20,18 @@
/* global window, dagTZ, moment, convertSecsToHumanReadable */
// We don't re-import moment again, otherwise webpack will include it twice in the bundle!
-import { defaultFormat, formatDateTime } from './datetime-utils';
import { escapeHtml } from './base';
+import { defaultFormat, formatDateTime } from './datetime-utils';
function makeDateTimeHTML(start, end) {
+ // check task ended or not
+ if (end && end instanceof moment) {
+ return (
+ `Started: ${start.format(defaultFormat)} <br> Ended: ${end.format(defaultFormat)} <br>`
+ )
+ }
return (
- `Started: ${start.format(defaultFormat)} <br> Ended: ${end.format(defaultFormat)} <br>`
+ `Started: ${start.format(defaultFormat)} <br> Ended: Not ended yet <br>`
)
}
@@ -47,13 +53,15 @@ function generateTooltipDateTimes(startDate, endDate, dagTZ) {
// Generate User's Local Start and End Date
startDate.tz(localTZ);
tooltipHTML += `<br><strong>Local: ${startDate.format(tzFormat)}</strong><br>`;
- tooltipHTML += makeDateTimeHTML(startDate, endDate.tz(localTZ));
+ const localEndDate = endDate && endDate instanceof moment ? endDate.tz(localTZ) : endDate;
+ tooltipHTML += makeDateTimeHTML(startDate, localEndDate);
// Generate DAG's Start and End Date
if (dagTZ !== 'UTC' && dagTZ !== localTZ) {
startDate.tz(dagTZ);
tooltipHTML += `<br><strong>DAG's TZ: ${startDate.format(tzFormat)}</strong><br>`;
- tooltipHTML += makeDateTimeHTML(startDate, endDate.tz(dagTZ));
+ const dagTZEndDate = endDate && endDate instanceof moment ? endDate.tz(dagTZ) : endDate;
+ tooltipHTML += makeDateTimeHTML(startDate, dagTZEndDate);
}
return tooltipHTML;
@@ -80,6 +88,12 @@ export default function tiTooltip(ti, {includeTryNumber = false} = {}) {
} else {
tt += `Started: ${escapeHtml(ti.start_date)}<br>`;
}
+ // Calculate duration on the fly if task instance is still running
+ if(ti.state === "running") {
+ let start_date = ti.start_date instanceof moment ? ti.start_date : moment(ti.start_date);
+ ti.duration = moment().diff(start_date, 'second')
+ }
+
tt += `Duration: ${escapeHtml(convertSecsToHumanReadable(ti.duration))}<br>`;
if (includeTryNumber) {