Progress
LoggingProgress
A progress tracker designed for batch environments (sbatch, etc.) that outputs clean, consistent progress updates to stdout/stderr.
Source code in easyroutine/console/progress.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
__init__(log_interval=5, update_frequency=0)
Initialize the logging progress tracker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_interval
|
int
|
How often to log progress updates (in seconds) |
5
|
update_frequency
|
int
|
Alternative to log_interval - update every N items (0 = use log_interval only) |
0
|
Source code in easyroutine/console/progress.py
33 34 35 36 37 38 39 40 41 42 43 | |
add_task(description, total=None, **kwargs)
Add a task to track.
Source code in easyroutine/console/progress.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
track(iterable, total=None, description='')
Track progress through an iterable.
Source code in easyroutine/console/progress.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
update(task_id, advance=1, **kwargs)
Update task progress.
Source code in easyroutine/console/progress.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
format_time(seconds)
Format seconds into a readable time string.
Source code in easyroutine/console/progress.py
136 137 138 139 140 141 142 143 144 145 | |
get_progress_bar(disable=False, force_batch_mode=False, log_interval=1, update_frequency=0)
Returns a progress tracker appropriate for the current environment.
In interactive environments (including interactive Slurm sessions), this will use a rich progress bar. In non-interactive batch jobs (like sbatch), it will use simpler text-based output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
disable
|
bool
|
If True, returns a No-Op progress object that does nothing. |
False
|
force_batch_mode
|
bool
|
If True, use the text-based progress tracker even in interactive environments. |
False
|
log_interval
|
int
|
How often (in seconds) to log progress in batch mode. |
1
|
update_frequency
|
int
|
In batch mode, update progress after this many items (0 means use only time-based updates) |
0
|
Returns:
| Type | Description |
|---|---|
|
A progress tracker compatible with the current environment. |
Source code in easyroutine/console/progress.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
is_non_interactive_batch()
Detect if running in a non-interactive batch job (like sbatch) where fancy progress bars won't display properly.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if in a non-interactive batch job, False otherwise |
Source code in easyroutine/console/progress.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
progress(iterable, description='', desc=None, total=None, disable=False, force_batch_mode=False, log_interval=1, update_frequency=0)
A tqdm-style progress bar that can be wrapped around an iterable.
This function automatically adapts to the environment: - In interactive sessions (including interactive Slurm jobs), it shows a rich progress bar - In non-interactive batch jobs (like sbatch), it uses simple text-based progress tracking
e.g. for i in progress(range(10)):
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
The iterable to wrap with a progress bar. |
required | |
description
|
str
|
Description to display. |
''
|
total
|
int
|
The total number of items. If None, it's inferred from len(iterable). |
None
|
disable
|
bool
|
If True, the progress bar is disabled completely. |
False
|
force_batch_mode
|
bool
|
If True, use text-based progress tracking even in interactive environments. |
False
|
log_interval
|
int
|
In batch mode, how often (in seconds) to log progress updates. |
1
|
update_frequency
|
int
|
In batch mode, update progress after processing this many items. Set to 0 to use only time-based updates. |
0
|
Source code in easyroutine/console/progress.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |