MCPcopy Index your code
hub / github.com/dask/dask / format_time

Function format_time

dask/diagnostics/progress.py:14–29  ·  view source on GitHub ↗

Format seconds into a human readable form. >>> format_time(10.4) # doctest: +SKIP '10.4s' >>> format_time(1000.4) # doctest: +SKIP '16min 40.4s'

(t)

Source from the content-addressed store, hash-verified

12
13@_deprecated(after_version="2022.6.0", use_instead="dask.utils.format_time")
14def format_time(t):
15 """Format seconds into a human readable form.
16
17 >>> format_time(10.4) # doctest: +SKIP
18 '10.4s'
19 >>> format_time(1000.4) # doctest: +SKIP
20 '16min 40.4s'
21 """
22 m, s = divmod(t, 60)
23 h, m = divmod(m, 60)
24 if h:
25 return f"{h:2.0f}hr {m:2.0f}min {s:4.1f}s"
26 elif m:
27 return f"{m:2.0f}min {s:4.1f}s"
28 else:
29 return f"{s:4.1f}s"
30
31
32class ProgressBar(Callback):

Callers 1

test_format_timeFunction · 0.90

Calls 1

divmodFunction · 0.50

Tested by 1

test_format_timeFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…