Skip to content

Commit e810b6f

Browse files
committed
Patch Duration unit cannot be a negative number nextflow-io#1384
1 parent 5b7f42e commit e810b6f

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

modules/nextflow/src/main/groovy/nextflow/trace/WorkflowStats.groovy

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,30 @@ class WorkflowStats {
105105
tot ? Math.round(failedCount / tot * 10000.0 as float) / 100.0 as float : 0
106106
}
107107

108+
protected Duration makeDuration(long value) {
109+
try {
110+
new Duration(value)
111+
}
112+
catch( Throwable e ) {
113+
log.warn "Oops... not a valid workflow stats duration value=$value", e
114+
return new Duration(0)
115+
}
116+
}
117+
108118
/**
109119
* @return Overall workflow compute time (CPUs-seconds) for task executed successfully
110120
*/
111-
Duration getSucceedDuration() { new Duration(succeedMillis) }
121+
Duration getSucceedDuration() { makeDuration(succeedMillis) }
112122

113123
/**
114124
* @return Overall workflow compute time (CPUs-seconds) for failed tasks
115125
*/
116-
Duration getFailedDuration() { new Duration(failedMillis) }
126+
Duration getFailedDuration() { makeDuration(failedMillis) }
117127

118128
/**
119129
* @return Overall workflow compute time (CPUs-seconds) for cached tasks
120130
*/
121-
Duration getCachedDuration() { new Duration(cachedMillis) }
131+
Duration getCachedDuration() { makeDuration(cachedMillis) }
122132

123133
/**
124134
* @return Succeed tasks count

0 commit comments

Comments
 (0)