Format seconds into human-readable time string.
(seconds: float)
| 31 | |
| 32 | |
| 33 | def _format_time(seconds: float) -> str: |
| 34 | """Format seconds into human-readable time string.""" |
| 35 | if seconds < 0 or seconds != seconds: # negative or NaN |
| 36 | return "?" |
| 37 | if seconds < 60: |
| 38 | return f"{seconds:.0f}s" |
| 39 | if seconds < 3600: |
| 40 | m, s = divmod(int(seconds), 60) |
| 41 | return f"{m}m{s:02d}s" |
| 42 | h, remainder = divmod(int(seconds), 3600) |
| 43 | m, s = divmod(remainder, 60) |
| 44 | return f"{h}h{m:02d}m" |
| 45 | |
| 46 | |
| 47 | class SlurmProgress: |