display
Manages formatting for displaying information to the console.
ConnProcess
Bases: Process
An extension of the multiprocessing's Process class that allows for custom handling of exceptions and inter-process communication.
This class overrides the run method to capture exceptions that occur
during the execution of the process and sends them back to the parent
process via a pipe. It also provides a property to retrieve any
exceptions that were raised during execution.
Attributes:
| Name | Type | Description |
|---|---|---|
_pconn |
Connection
|
The parent connection for inter-process communication. |
_cconn |
Connection
|
The child connection for inter-process communication. |
exception |
Union[Exception, None]
|
Stores the exception raised during the process run. |
Methods:
| Name | Description |
|---|---|
run |
Executes the process's main logic. |
Source code in merlin/display.py
exception
property
Retrieves the exception raised during the process execution.
This property checks if there is an exception available from the parent connection. If an exception was raised, it is received and stored for later access.
Returns:
| Type | Description |
|---|---|
Union[Exception, None]
|
The exception raised during the process run, or None if no exception occurred. |
run()
Executes the process's main logic.
This method overrides the default run method of the Process class. It attempts to run the process and captures any exceptions that occur. If an exception is raised, it sends the exception and its traceback back to the parent process via the child connection.
Source code in merlin/display.py
check_server_access(sconf)
Check if there are any issues connecting to the servers. If there are, output the errors.
This function iterates through a predefined list of servers and checks their connectivity based on the provided server configuration. If any connection issues are detected, the exceptions are collected and printed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sconf
|
Dict[str, Any]
|
A dictionary containing server configurations, where keys represent server names and values contain connection details. The function expects keys corresponding to the servers being checked. |
required |
Source code in merlin/display.py
display_config_info()
Prints useful configuration information for the Merlin application to the console.
This function retrieves and displays the connection strings and SSL configurations for the broker and results servers. It handles any exceptions that may occur during the retrieval process, providing error messages for any issues encountered.
Source code in merlin/display.py
display_multiple_configs(files, configs)
Logic for displaying multiple Merlin config files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
List[str]
|
List of merlin config files |
required |
configs
|
List[Dict]
|
List of merlin configurations |
required |
Source code in merlin/display.py
display_progress_bar(current, total, state_info=None, prefix='', suffix='', decimals=1, length=80, fill='█', print_end='\n', color=None, cb_help=False)
Prints a customizable progress bar that visually represents the completion percentage relative to a given total.
The function can display additional state information for detailed tracking, including support for color customization and adaptation for color-blind users. It updates the display based on current progress and optionally accepts state information to adjust the appearance of the progress bar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current
|
int
|
Current progress value. |
required |
total
|
int
|
Total value representing 100% completion. |
required |
state_info
|
Dict[str, Any]
|
Dictionary containing state information about tasks. This can override color settings and modifies how the progress bar is displayed. |
None
|
prefix
|
str
|
Optional prefix string to display before the progress bar. |
''
|
suffix
|
str
|
Optional suffix string to display after the progress bar. |
''
|
decimals
|
int
|
Number of decimal places to display in the percentage (default is 1). |
1
|
length
|
int
|
Character length of the progress bar (default is 80). |
80
|
fill
|
str
|
Character used to fill the progress bar (default is "█"). |
'█'
|
print_end
|
str
|
Character(s) to print at the end of the line (e.g., '\r', '\n'). |
'\n'
|
color
|
str
|
ANSI color string for the progress bar. Overrides state_info colors. |
None
|
cb_help
|
bool
|
If True, provides color-blind assistance by adapting the fill characters. |
False
|
Source code in merlin/display.py
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 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |
display_status_summary(status_obj, non_workspace_keys, test_mode=False)
Displays a high-level overview of the status of a study, including progress bars for each step and a summary of the number of initialized, running, finished, cancelled, dry ran, failed, and unknown tasks.
The function prints a summary for each step and collects state information. In test mode, it suppresses output and returns a dictionary of state information instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_obj
|
Status
|
An instance of |
required |
non_workspace_keys
|
set
|
A set of keys in requested_statuses that are not workspace keys. Typically includes keys like "parameters", "task_queue", and "workers". |
required |
test_mode
|
bool
|
If True, runs in test mode; suppresses printing and returns a dictionary of state information for each step. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
Dict
|
An empty dictionary in regular mode. In test mode, returns a dictionary containing the state information for each step. |
Source code in merlin/display.py
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 | |
display_status_task_by_task(status_obj, test_mode=False)
Displays a low-level overview of the status of a study in a task-by-task format.
Each task will display the following details
- Step name
- Worker name
- Task queue
- Command and restart parameters
- Step workspace
- Step status
- Return code
- Elapsed time
- Run time
- Number of restarts
If the number of tasks exceeds a certain limit and the pager is disabled, the user will be prompted to apply additional filters to avoid overwhelming the terminal output, unless the prompts are disabled through the no-prompts flag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_obj
|
DetailedStatus
|
An instance of
|
required |
test_mode
|
bool
|
If True, runs the function in testing mode, suppressing output and reducing the task limit for prompts. Defaults to False. |
False
|
Source code in merlin/display.py
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 | |
print_info(args)
Provide version and location information about python and packages to facilitate user troubleshooting. Also provides info about server connections and configurations.
Note
The args parameter is currently unused but is included for
compatibility with the command-line interface (CLI) in case we decide to use
args here in the future.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
parsed CLI arguments (currently unused). |
required |