task_manager¶
task_manager
¶
Author: Corentin Ravoux
Description : Task manager developed to launch several Tomography jobs. Tested on Cobalt and Irene clusters.
Machine
¶
Machine(ending_str, error_str, wait_check)
Bases: object
Base class for a compute backend that launches solver jobs.
A machine knows how to write a launcher script, submit it, and detect job
completion/errors from the solver log files. Concrete subclasses are
:class:Nersc, :class:Irene (SLURM/MSUB clusters) and :class:Bash
(local execution).
Attributes:
| Name | Type | Description |
|---|---|---|
ending_str |
str
|
Log line marking a successful job end. |
error_str |
list[str]
|
Tokens whose presence in a log flags an error. |
wait_check |
bool
|
Whether the manager should poll for completion. |
Initialise the machine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ending_str
|
str
|
Log line marking successful completion. |
required |
error_str
|
list[str]
|
First-token markers indicating an error. |
required |
wait_check
|
bool
|
Whether to wait/poll for job completion. |
required |
Source code in lelantos/task_manager.py
46 47 48 49 50 51 52 53 54 55 56 | |
is_finished
¶
is_finished(f)
Return True if the log lines contain the completion marker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
list[str]
|
Lines of a solver output/log file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if |
Source code in lelantos/task_manager.py
58 59 60 61 62 63 64 65 66 67 68 69 70 | |
gives_error
¶
gives_error(f)
Return True if the log lines contain an error marker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
list[str]
|
Lines of a solver error/log file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if the first token of any line matches |
Source code in lelantos/task_manager.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
load_cluster_optional_arguments
¶
load_cluster_optional_arguments()
Read the (N, n, c) SLURM resource counts from kwargs.
Returns:
| Type | Description |
|---|---|
|
tuple[int, int, int]: |
|
|
cpus-per-task, each defaulting to 1. |
Source code in lelantos/task_manager.py
87 88 89 90 91 92 93 94 95 96 97 | |
Nersc
¶
Nersc(**kwargs)
Bases: Machine
SLURM (sbatch) launcher for the NERSC cluster.
Supports two launch modes selected by the mode kwarg: "separated"
(one sbatch job per sub-map) or "unified" (a single job running all
sub-maps with srun ... & + wait).
Initialise the NERSC machine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Optional SLURM parameters ( |
{}
|
Source code in lelantos/task_manager.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
create_launcher
¶
create_launcher(pwd, dir_paths, software_command_lines, software_name)
Write the SLURM launcher(s), dispatching on the launch mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pwd
|
str
|
Working directory (used for the unified launcher). |
required |
dir_paths
|
list[str]
|
Per-sub-map run directories. |
required |
software_command_lines
|
list[str]
|
Solver command per sub-map. |
required |
software_name
|
str
|
Job name / solver identifier. |
required |
Source code in lelantos/task_manager.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
create_launcher_separated
¶
create_launcher_separated(dir_paths, software_command_lines, software_name)
Write one SLURM batch script per sub-map directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_paths
|
list[str]
|
Per-sub-map run directories. |
required |
software_command_lines
|
list[str]
|
Solver command per sub-map. |
required |
software_name
|
str
|
Job name / solver identifier. |
required |
Source code in lelantos/task_manager.py
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 | |
create_launcher_unified
¶
create_launcher_unified(pwd, dir_paths, software_command_lines, software_name)
Write a single SLURM script running all sub-maps concurrently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pwd
|
str
|
Directory where the unified launcher is written. |
required |
dir_paths
|
list[str]
|
Per-sub-map run directories. |
required |
software_command_lines
|
list[str]
|
Solver command per sub-map. |
required |
software_name
|
str
|
Job name / solver identifier. |
required |
Source code in lelantos/task_manager.py
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 212 213 214 215 216 217 218 219 220 | |
launch_unified
¶
launch_unified(pwd)
Submit the single unified SLURM launcher via sbatch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pwd
|
str
|
Directory containing the unified launcher. |
required |
Source code in lelantos/task_manager.py
222 223 224 225 226 227 228 | |
launch_separated
¶
launch_separated(dir_paths)
Submit one SLURM job per sub-map directory via sbatch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_paths
|
list[str]
|
Per-sub-map run directories. |
required |
Source code in lelantos/task_manager.py
230 231 232 233 234 235 236 237 | |
launch
¶
launch(dir_paths=None, pwd=None, software_command_lines=None, software_name=None)
Submit the NERSC job(s), dispatching on the launch mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_paths
|
list[str]
|
Per-sub-map run directories. |
None
|
pwd
|
str
|
Working directory (unified mode). |
None
|
software_command_lines
|
list[str]
|
Unused here. |
None
|
software_name
|
str
|
Unused here. |
None
|
Source code in lelantos/task_manager.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
Irene
¶
Irene(**kwargs)
Bases: Machine
MSUB (ccc_msub) launcher for the TGCC Irene cluster.
Initialise the Irene machine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Optional scheduler parameters ( |
{}
|
Source code in lelantos/task_manager.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
create_launcher
¶
create_launcher(pwd, dir_paths, software_command_lines, software_name)
Write one MSUB batch script per sub-map directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pwd
|
str
|
Unused (kept for interface parity with other machines). |
required |
dir_paths
|
list[str]
|
Per-sub-map run directories. |
required |
software_command_lines
|
list[str]
|
Solver command per sub-map. |
required |
software_name
|
str
|
Job name / solver identifier. |
required |
Source code in lelantos/task_manager.py
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 | |
launch
¶
launch(dir_paths=None, pwd=None, software_command_lines=None, software_name=None)
Submit one MSUB job per sub-map directory via ccc_msub.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_paths
|
list[str]
|
Per-sub-map run directories. |
None
|
pwd
|
str
|
Unused. |
None
|
software_command_lines
|
list[str]
|
Unused. |
None
|
software_name
|
str
|
Unused. |
None
|
Source code in lelantos/task_manager.py
315 316 317 318 319 320 321 322 323 324 325 326 327 | |
Bash
¶
Bash(ending_str='', error_str=[], **kwargs)
Bases: Machine
Local (no scheduler) launcher running the solver via subprocess.
Runs jobs serially, or in parallel with a :mod:multiprocessing pool when
the n kwarg is greater than 1.
Initialise the Bash machine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ending_str
|
str
|
Completion marker (usually taken from the solver). |
''
|
error_str
|
list[str]
|
Error markers. |
[]
|
**kwargs
|
Optional parameters; |
{}
|
Source code in lelantos/task_manager.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
create_launcher
¶
create_launcher(pwd, dir_path, command_line, software_name)
No-op: local execution needs no launcher script.
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
An empty tuple. |
Source code in lelantos/task_manager.py
352 353 354 355 356 357 358 | |
launch
¶
launch(dir_paths=None, pwd=None, software_command_lines=None, software_name=None)
Run the solver locally, serially or in parallel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_paths
|
list[str]
|
Per-sub-map run directories. |
None
|
pwd
|
str
|
Unused. |
None
|
software_command_lines
|
list[str]
|
Solver command per sub-map. |
None
|
software_name
|
str
|
Solver identifier (log file names). |
None
|
Source code in lelantos/task_manager.py
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 | |
launch_parallel
¶
launch_parallel(number_process, dir_paths=None, pwd=None, software_command_lines=None, software_name=None)
Run the sub-map solver jobs concurrently in a process pool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number_process
|
int
|
Pool size. |
required |
dir_paths
|
list[str]
|
Per-sub-map run directories. |
None
|
pwd
|
str
|
Unused. |
None
|
software_command_lines
|
list[str]
|
Solver command per sub-map. |
None
|
software_name
|
str
|
Solver identifier (log file names). |
None
|
Source code in lelantos/task_manager.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
launch_single
¶
launch_single(software_name, param_launch)
Run one solver command, redirecting stdout/stderr to log files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
software_name
|
str
|
Solver identifier (used for log file names). |
required |
param_launch
|
list
|
|
required |
Source code in lelantos/task_manager.py
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | |
launch_serial
¶
launch_serial(dir_paths=None, pwd=None, software_command_lines=None, software_name=None)
Run the sub-map solver jobs one after another.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_paths
|
list[str]
|
Per-sub-map run directories. |
None
|
pwd
|
str
|
Unused. |
None
|
software_command_lines
|
list[str]
|
Solver command per sub-map. |
None
|
software_name
|
str
|
Solver identifier (log file names). |
None
|
Source code in lelantos/task_manager.py
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 | |
TomographySoftware
¶
TomographySoftware(exec_file)
Bases: object
Base class for a tomographic solver wrapped by the manager.
Attributes:
| Name | Type | Description |
|---|---|---|
exec_file |
str
|
Path to the solver executable. |
Initialise the solver wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exec_file
|
str
|
Path to the solver executable. |
required |
Source code in lelantos/task_manager.py
466 467 468 469 470 471 472 | |
Other
¶
Other()
Bases: TomographySoftware
Placeholder solver backend (other.exe) for a custom algorithm.
Locate the other.exe executable in the package exec folder.
Source code in lelantos/task_manager.py
480 481 482 483 484 485 486 487 | |
create_input
¶
create_input(dir_path, launcher_params, name)
No-op input writer for the placeholder solver.
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
An empty tuple. |
Source code in lelantos/task_manager.py
489 490 491 492 493 494 495 | |
Dachshund
¶
Dachshund()
Bases: TomographySoftware
Wrapper for the Dachshund Wiener-filter tomography solver.
Locate the dachshund.exe executable in the package exec folder.
Source code in lelantos/task_manager.py
503 504 505 506 507 508 509 510 511 | |
create_input
¶
create_input(dir_paths, launcher_params, launcher_names)
Write the Dachshund .cfg input file for each sub-map.
Each file declares the box size, pixel count, map grid, signal covariance (sigma_f, l_perp, l_par), PCG solver settings and the input/output binary paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_paths
|
list[str]
|
Per-sub-map run directories. |
required |
launcher_params
|
list[dict]
|
Per-sub-map geometry/solver params
(keys |
required |
launcher_names
|
list[str]
|
Config file name for each sub-map. |
required |
Source code in lelantos/task_manager.py
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 | |
TomographyManager
¶
TomographyManager(pwd, software, machine, name_pixel, launch_file, symlink_folder=None, **kwargs)
Bases: object
Orchestrate tomographic solver runs on a chosen machine.
Loads the launch description (a pickle listing sub-map names and their solver parameters), sets up temporary run directories, writes the solver inputs and machine launchers, submits the jobs, waits for completion, checks for errors and copies the resulting maps back.
Attributes:
| Name | Type | Description |
|---|---|---|
available_software |
tuple[str]
|
Supported solver names. |
available_machine |
tuple[str]
|
Supported machine names. |
Initialise the manager and its machine/software backends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pwd
|
str
|
Run/output directory for the tomography. |
required |
software
|
str
|
Solver name ( |
required |
machine
|
str
|
Machine name ( |
required |
name_pixel
|
str
|
Path to the input pixel binary. |
required |
launch_file
|
str
|
Pickle listing sub-map names and solver params. |
required |
symlink_folder
|
str
|
If set, run inside a symlink to this folder (e.g. cluster scratch). |
None
|
**kwargs
|
Machine-specific options (e.g. |
{}
|
Source code in lelantos/task_manager.py
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 | |
init_sofware
¶
init_sofware(software)
Instantiate the solver backend selected by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
software
|
str
|
Solver name (case-insensitive). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
TomographySoftware |
The solver wrapper, or a |
|
|
if the name is unknown. |
Source code in lelantos/task_manager.py
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 | |
init_machine
¶
init_machine(machine, **kwargs)
Instantiate the machine backend selected by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
machine
|
str
|
Machine name (case-insensitive). |
required |
**kwargs
|
Machine-specific options. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
Machine |
The machine backend, or a |
|
|
name is unknown. |
Source code in lelantos/task_manager.py
656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 | |
create_python_dir
staticmethod
¶
create_python_dir(pwd)
Create the Tmp working sub-directory if absent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pwd
|
str
|
Parent directory. |
required |
Source code in lelantos/task_manager.py
678 679 680 681 682 683 684 685 686 | |
create_dir
staticmethod
¶
create_dir(pwd, dirnames)
Create one Tmp/<name> run directory per sub-map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pwd
|
str
|
Parent directory. |
required |
dirnames
|
list[str]
|
Sub-map directory names. |
required |
Source code in lelantos/task_manager.py
688 689 690 691 692 693 694 695 696 697 698 699 | |
create_file
staticmethod
¶
create_file(name)
Create a placeholder log file containing "wait" if absent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
File path. |
required |
Source code in lelantos/task_manager.py
701 702 703 704 705 706 707 708 709 710 711 | |
is_finished
¶
is_finished(file_lines)
Delegate completion detection to the machine backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_lines
|
list[str]
|
Lines of a solver output file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if the job completed. |
Source code in lelantos/task_manager.py
713 714 715 716 717 718 719 720 721 722 | |
gives_error
¶
gives_error(file_lines)
Delegate error detection to the machine backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_lines
|
list[str]
|
Lines of a solver error file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if the log signals an error. |
Source code in lelantos/task_manager.py
724 725 726 727 728 729 730 731 732 733 | |
wait_until_finished
¶
wait_until_finished(pwd, listname)
Poll the sub-map output files until every job has completed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pwd
|
str
|
Parent run directory. |
required |
listname
|
list[str]
|
Sub-map directory names to monitor. |
required |
Source code in lelantos/task_manager.py
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 | |
check_errors
¶
check_errors(pwd, listname)
Scan each sub-map error file and log whether it reported an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pwd
|
str
|
Parent run directory. |
required |
listname
|
list[str]
|
Sub-map directory names to check. |
required |
Source code in lelantos/task_manager.py
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 | |
all_finished
¶
all_finished(listFinished)
Return True only if every entry of the status list is True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
listFinished
|
list[bool]
|
Per-sub-map completion flags. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True if all jobs are finished. |
Source code in lelantos/task_manager.py
775 776 777 778 779 780 781 782 783 784 785 786 787 788 | |
copy_files
¶
copy_files(dir_paths, listname)
Copy each sub-map's pixel input into its run directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_paths
|
list[str]
|
Per-sub-map run directories. |
required |
listname
|
list[str]
|
Sub-map names (pixel file suffixes). |
required |
Source code in lelantos/task_manager.py
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 | |
create_machine_launcher
¶
create_machine_launcher(dir_paths, launcher_params)
Write the solver inputs and the machine launcher scripts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_paths
|
list[str]
|
Per-sub-map run directories. |
required |
launcher_params
|
list[dict]
|
Per-sub-map solver parameters. |
required |
Source code in lelantos/task_manager.py
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 | |
launch
¶
launch(dir_paths, launcher_params)
Submit the solver jobs on the configured machine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_paths
|
list[str]
|
Per-sub-map run directories. |
required |
launcher_params
|
list[dict]
|
Per-sub-map solver parameters. |
required |
Source code in lelantos/task_manager.py
828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 | |
treat_launch
¶
treat_launch(pwd, listname)
Optionally wait for completion, then check for errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pwd
|
str
|
Parent run directory. |
required |
listname
|
list[str]
|
Sub-map directory names. |
required |
Source code in lelantos/task_manager.py
851 852 853 854 855 856 857 858 859 860 861 | |
launch_all
¶
launch_all()
Run the full launch sequence for all sub-maps.
Loads the launch pickle, creates the temporary run directories, copies inputs, writes launchers, submits the jobs, logs them and finally waits for completion / checks for errors.
Source code in lelantos/task_manager.py
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 | |
copy
¶
copy()
Copy each sub-map's output map from Tmp back to pwd.
Source code in lelantos/task_manager.py
887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 | |
remove_tmp
¶
remove_tmp()
Delete the temporary Tmp run directory tree.
Source code in lelantos/task_manager.py
904 905 906 | |
link_tomography_folder
¶
link_tomography_folder(symlink_folder)
Replace pwd with a symlink to an external folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symlink_folder
|
str
|
Target directory (created if missing); the
run directory |
required |
Source code in lelantos/task_manager.py
908 909 910 911 912 913 914 915 916 917 918 919 920 921 | |