guidellm.utils.console
Console utilities for rich terminal output and status updates.
Provides an extended Rich console with custom formatting for status messages, progress tracking, and tabular data display. Includes predefined color schemes, status levels, icons, and styles for consistent terminal output across the application. Supports multi-step operations with spinners and context managers for clean progress reporting.
Colors
Color constants for console styling.
Provides standardized color schemes for different message types and branding. Colors are defined using Rich console color names or hex values.
Attributes:
| Name | Type | Description |
|---|---|---|
info | str | Color for informational messages |
progress | str | Color for progress indicators |
success | str | Color for successful operations |
warning | str | Color for warning messages |
error | str | Color for error messages |
primary | str | Primary brand color |
secondary | str | Secondary brand color |
tertiary | str | Tertiary brand color |
Source code in src/guidellm/utils/console.py
Console
Bases: Console
Extended Rich console with custom formatting and status reporting.
Enhances Rich's Console with specialized methods for status messages, progress tracking with spinners, and formatted table output. Provides consistent styling through predefined status levels, icons, and colors. Supports quiet mode to suppress non-critical output.
Example: :: console = Console() console.print_update("Starting process", status="info") with console.print_update_step("Loading data") as step: step.update("Processing items") step.finish("Complete", status_level="success")
Source code in src/guidellm/utils/console.py
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 212 213 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 266 267 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 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |
print_table(header_cols, value_cols, title=None, widths=None, apply_formatting=True, print_bottom_divider=True)
Print a formatted table with headers and values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
header_cols | Sequence[str | list[str]] | List of header columns, each string or list of strings | required |
value_cols | Sequence[str | list[str]] | List of value columns, each string or list of strings | required |
title | str | None | Optional title to display before table | None |
widths | Sequence[int] | None | Optional minimum column widths to enforce | None |
apply_formatting | bool | Whether to calculate widths and format columns | True |
print_bottom_divider | bool | Whether to print bottom border line | True |
Source code in src/guidellm/utils/console.py
print_table_divider(widths, char)
Print a horizontal divider line across table columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
widths | Sequence[int] | Column widths for divider line | required |
char | str | Character to use for divider line (e.g., '=', '-') | required |
Source code in src/guidellm/utils/console.py
print_table_headers(headers, widths)
Print header rows with support for column spanning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headers | Sequence[list[str]] | List of header columns, each containing header row values | required |
widths | Sequence[int] | Column widths for proper alignment | required |
Source code in src/guidellm/utils/console.py
print_table_row(values, widths=None, spacer=' ', divider='|', cell_style='', value_style='', divider_style='', edge_style='')
Print a single table row with custom styling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values | Sequence[str] | Cell values for the row | required |
widths | Sequence[int] | None | Column widths, defaults to value lengths | None |
spacer | str | Character for padding cells | ' ' |
divider | str | Character separating columns | '|' |
cell_style | str | Rich style string for entire cells | '' |
value_style | str | Rich style string for cell values only | '' |
divider_style | str | Rich style string for column dividers | '' |
edge_style | str | Rich style string for table edges | '' |
Source code in src/guidellm/utils/console.py
print_table_values(values, widths)
Print all data rows in the table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values | Sequence[list[str]] | List of value columns, each containing row values | required |
widths | Sequence[int] | Column widths for proper alignment | required |
Source code in src/guidellm/utils/console.py
print_tables(header_cols_groups, value_cols_groups, title=None, widths=None)
Print multiple tables with uniform column widths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
header_cols_groups | Sequence[Sequence[str | list[str]]] | List of header column groups for each table | required |
value_cols_groups | Sequence[Sequence[str | list[str]]] | List of value column groups for each table | required |
title | str | None | Optional title to display before tables | None |
widths | Sequence[int] | None | Optional minimum column widths to enforce | None |
Source code in src/guidellm/utils/console.py
print_update(title, details=None, status='info')
Print a status message with icon and optional details.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title | str | Main status message to display | required |
details | Any | None | Optional additional details shown indented below message | None |
status | StatusLevel | Status level determining icon and styling | 'info' |
Source code in src/guidellm/utils/console.py
print_update_details(details)
Print additional details indented below a status message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
details | Any | None | Content to display, converted to string and styled dimly | required |
Source code in src/guidellm/utils/console.py
print_update_step(title, status='info', details=None, spinner='dots')
Create a context manager for multi-step progress with spinner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title | str | Initial progress message to display | required |
status | StatusLevel | Initial status level for styling | 'info' |
details | Any | None | Optional details to show after completion | None |
spinner | str | Spinner animation style name | 'dots' |
Returns:
| Type | Description |
|---|---|
ConsoleUpdateStep | ConsoleUpdateStep context manager for progress tracking |
Source code in src/guidellm/utils/console.py
ConsoleUpdateStep dataclass
Context manager for multi-step progress operations with spinner.
Displays animated spinner during operation execution and allows dynamic status updates. Automatically stops spinner on exit and prints final status message. Designed for use with Python's with statement.
Example: :: console = Console() with console.print_update_step("Processing data") as step: step.update("Loading files", "info") # ... do work ... step.finish("Completed successfully", status_level="success")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
console | Console | The Console instance to use for output | required |
title | str | Initial progress message to display | required |
details | Any | None | Optional additional details to show after completion | None |
status_level | StatusLevel | Initial status level determining style and icon | 'info' |
spinner | str | Spinner animation style name from Rich's spinner set | 'dots' |
Source code in src/guidellm/utils/console.py
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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
finish(title, details=None, status_level='info')
Stop the spinner and print the final status message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title | str | Final completion message to display | required |
details | Any | None | Optional additional information to show below message | None |
status_level | StatusLevel | Status level for final message styling | 'info' |
Source code in src/guidellm/utils/console.py
update(title, status_level=None)
Update the progress message and optionally the status level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title | str | New progress message to display | required |
status_level | StatusLevel | None | Optional new status level to apply | None |