study_da
GenerateScan
A class to generate a study (along with the corresponding tree) from a parameter file, and potentially a set of template files.
Attributes:
| Name | Type | Description |
|---|---|---|
config |
dict
|
The configuration dictionary. |
ryaml |
YAML
|
The YAML parser. |
dic_common_parameters |
dict
|
Dictionary of common parameters across generations. |
Methods:
| Name | Description |
|---|---|
__init__ |
Initializes the generation scan with a configuration file or dictionary. |
render |
Renders the study file using a template. |
write |
Writes the study file to disk. |
generate_render_write |
Generates, renders, and writes the study file. |
get_dic_parametric_scans |
Retrieves dictionaries of parametric scan values. |
parse_parameter_space |
Parses the parameter space for a given parameter. |
browse_and_collect_parameter_space |
Browses and collects the parameter space for a given generation. |
postprocess_parameter_lists |
Postprocesses the parameter lists. |
create_scans |
Creates study files for parametric scans. |
complete_tree |
Completes the tree structure of the study dictionary. |
write_tree |
Writes the study tree structure to a YAML file. |
create_study_for_current_gen |
Creates study files for the current generation. |
create_study |
Creates study files for the entire study. |
eval_conditions |
Evaluates the conditions to filter out some parameter values. |
filter_for_concomitant_parameters |
Filters the conditions for concomitant parameters. |
Source code in study_da/generate/generate_scan.py
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 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 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 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 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 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 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 | |
__init__(path_config=None, dic_scan=None)
Initialize the generation scan with a configuration file or dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_config
|
Optional[str]
|
Path to the configuration file for the scan. Default is None. |
None
|
dic_scan
|
Optional[dict[str, Any]]
|
Dictionary containing the scan configuration. Default is None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither or both of |
Source code in study_da/generate/generate_scan.py
browse_and_collect_parameter_space(generation)
Browses and collects the parameter space for a given generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
generation
|
str
|
The generation name. |
required |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, Any], dict[str, Any], dict[str, Any], list[list[str]], list[str]]
|
tuple[dict[str, Any], dict[str, Any], dict[str, Any], list[list[str]]]: The updated dictionaries of parameter lists. |
Source code in study_da/generate/generate_scan.py
complete_tree(dictionary_tree, l_study_path_next_gen, gen)
Completes the tree structure of the study dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dictionary_tree
|
dict
|
The dictionary representing the study tree structure. |
required |
l_study_path_next_gen
|
list[str]
|
The list of study paths for the next gen. |
required |
gen
|
str
|
The generation name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The updated dictionary representing the study tree structure. |
Source code in study_da/generate/generate_scan.py
create_scans(generation, generation_path, template_path, depth_gen, dic_parameter_lists=None, dic_parameter_lists_for_naming=None, add_prefix_to_folder_names=False)
Creates study files for parametric scans. If a dictionary of parameter lists is provided, the scan will be done on the parameter lists (no cartesian product). Otherwise, the scan will be done on the cartesian product of the parameters defined in the scan configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
generation
|
str
|
The generation name. |
required |
generation_path
|
str
|
The (relative) path to the generation folder. |
required |
template_path
|
str
|
The path to the template folder. |
required |
depth_gen
|
int
|
The depth of the generation in the tree. |
required |
dic_parameter_lists
|
Optional[dict[str, Any]]
|
The dictionary of parameter lists. Defaults to None. |
None
|
dic_parameter_lists_for_naming
|
Optional[dict[str, Any]]
|
The dictionary of parameter lists for naming. Defaults to None. |
None
|
add_prefix_to_folder_names
|
bool
|
Whether to add a prefix to the folder names. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
list[str]
|
tuple[list[str], list[str]]: The list of study file strings and the list of study paths. |
Source code in study_da/generate/generate_scan.py
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 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 | |
create_study(tree_file=True, force_overwrite=False, dic_parameter_all_gen=None, dic_parameter_all_gen_naming=None, add_prefix_to_folder_names=False)
Creates study files for the entire study.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tree_file
|
bool
|
Whether to write the study tree structure to a YAML file. Defaults to True. |
True
|
force_overwrite
|
bool
|
Whether to overwrite existing study files. Defaults to False. |
False
|
dic_parameter_all_gen
|
Optional[dict[str, dict[str, Any]]]
|
The dictionary of parameter lists for all generations. Defaults to None. |
None
|
dic_parameter_all_gen_naming
|
Optional[dict[str, dict[str, Any]]]
|
The dictionary of parameter lists for all generations for naming. Defaults to None. |
None
|
add_prefix_to_folder_names
|
bool
|
Whether to add a prefix to the folder names. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
None
|
list[str]: The list of study file strings. |
Source code in study_da/generate/generate_scan.py
create_study_for_current_gen(generation, generation_path, depth_gen, dic_parameter_lists=None, dic_parameter_lists_for_naming=None, add_prefix_to_folder_names=False)
Creates study files for the current generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
generation
|
str
|
The name of the current generation. |
required |
directory_path
|
str
|
The (relative) path to the directory folder for the current generation. |
required |
depth_gen
|
int
|
The depth of the generation in the tree. |
required |
dic_parameter_lists
|
Optional[dict[str, Any]]
|
The dictionary of parameter lists. Defaults to None. |
None
|
dic_parameter_lists_for_naming
|
Optional[dict[str, Any]]
|
The dictionary of parameter lists for naming. Defaults to None. |
None
|
add_prefix_to_folder_names
|
bool
|
Whether to add a prefix to the folder names. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
list[str]
|
tuple[list[str], list[str]]: The list of study file strings and the list of study paths. |
Source code in study_da/generate/generate_scan.py
eval_conditions(l_condition, dic_parameter_lists)
staticmethod
Evaluates the conditions to filter out some parameter values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
l_condition
|
list[str]
|
The list of conditions. |
required |
dic_parameter_lists
|
dict[str
|
Any]): The dictionary of parameter lists. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The array of conditions. |
Source code in study_da/generate/generate_scan.py
filter_for_concomitant_parameters(array_conditions, ll_concomitant_parameters, dic_dimension_indices)
staticmethod
Filters the conditions for concomitant parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array_conditions
|
ndarray
|
The array of conditions. |
required |
ll_concomitant_parameters
|
list[list[str]]
|
The list of concomitant parameters. |
required |
dic_dimension_indices
|
dict[str, int]
|
The dictionary of dimension indices. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The filtered array of conditions. |
Source code in study_da/generate/generate_scan.py
generate_render_write(gen_name, job_directory_path, template_path, depth_gen, dic_mutated_parameters={})
Generates, renders, and writes the study file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gen_name
|
str
|
The name of the generation. |
required |
study_path
|
str
|
The path to the job folder. |
required |
template_path
|
str
|
The path to the template folder. |
required |
depth_gen
|
int
|
The depth of the generation in the tree. |
required |
dic_mutated_parameters
|
dict[str, Any]
|
The dictionary of mutated parameters. Defaults to {}. |
{}
|
Returns:
| Type | Description |
|---|---|
list[str]
|
tuple[str, list[str]]: The study file string and the list of study paths. |
Source code in study_da/generate/generate_scan.py
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 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 | |
get_dic_parametric_scans(generation)
Retrieves dictionaries of parametric scan values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
generation
|
str
|
The generation name. |
required |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, Any], dict[str, Any], ndarray | None]
|
tuple[dict[str, Any], dict[str, Any], np.ndarray|None]: The dictionaries of parametric scan values, another dictionnary with better naming for the tree creation, and an array of conditions to filter out some parameter values. |
Source code in study_da/generate/generate_scan.py
parse_parameter_space(parameter, dic_curr_parameter, dic_parameter_lists, dic_parameter_lists_for_naming)
Parses the parameter space for a given parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameter
|
str
|
The parameter name. |
required |
dic_curr_parameter
|
dict[str, Any]
|
The dictionary of current parameter values. |
required |
dic_parameter_lists
|
dict[str, Any]
|
The dictionary of parameter lists. |
required |
dic_parameter_lists_for_naming
|
dict[str, Any]
|
The dictionary of parameter lists for naming. |
required |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, Any], dict[str, Any]]
|
tuple[dict[str, Any], dict[str, Any]]: The updated dictionaries of parameter lists. |
Source code in study_da/generate/generate_scan.py
postprocess_parameter_lists(dic_parameter_lists, dic_parameter_lists_for_naming, dic_subvariables)
Post-processes parameter lists by ensuring values are not numpy types and handling nested parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dic_parameter_lists
|
dict[str, Any]
|
Dictionary containing parameter lists. |
required |
dic_parameter_lists_for_naming
|
dict[str, Any]
|
Dictionary containing parameter lists for naming. |
required |
dic_subvariables
|
dict[str, Any]
|
Dictionary containing subvariables for nested parameters. |
required |
Returns:
| Type | Description |
|---|---|
tuple[dict[str, Any], dict[str, Any]]
|
tuple[dict[str, Any], dict[str, Any]]: Updated dictionaries of parameter lists and parameter lists for naming. |
Source code in study_da/generate/generate_scan.py
render(str_parameters, template_path, path_main_configuration, study_path=None, str_dependencies=None)
Renders the study file using a template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
str_parameters
|
str
|
The string representation of parameters to declare/mutate. |
required |
template_path
|
str
|
The path to the template file. |
required |
path_main_configuration
|
str
|
The path to the main configuration file. |
required |
study_path
|
str
|
The path to the root of the study. Defaults to None. |
None
|
dependencies
|
dict[str, str]
|
The dictionary of dependencies. Defaults to {}. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The rendered study file. |
Source code in study_da/generate/generate_scan.py
write(study_str, file_path, format_with_black=True)
Writes the study file to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
study_str
|
str
|
The study file string. |
required |
file_path
|
str
|
The path to write the study file. |
required |
format_with_black
|
bool
|
Whether to format the output file with black. Defaults to True. |
True
|
Source code in study_da/generate/generate_scan.py
write_tree(dictionary_tree)
Writes the study tree structure to a YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dictionary_tree
|
dict
|
The dictionary representing the study tree structure. |
required |
Source code in study_da/generate/generate_scan.py
SubmitScan
Source code in study_da/submit/submit_scan.py
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 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 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 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 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 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 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 | |
dic_tree: dict
property
writable
Loads the dictionary tree from the path.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The loaded dictionary tree. |
__init__(path_tree, path_python_environment='', path_python_environment_container='', path_container_image=None)
Initializes the SubmitScan class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_tree
|
str
|
The path to the tree structure. |
required |
path_python_environment
|
str
|
The path to the Python environment. Defaults to "". |
''
|
path_python_environment_container
|
str
|
The path to the Python environment in the container. Defaults to "". |
''
|
path_container_image
|
Optional[str]
|
The path to the container image. Defaults to None. |
None
|
Source code in study_da/submit/submit_scan.py
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 | |
check_and_update_all_jobs_status()
Checks the status of all jobs and updates their status in the job dictionary.
This method iterates through all jobs, checks if a ".finished" or a ".failed" file exists in the job's folder, and updates the job's status accordingly. If at least one job is not finished or failed, the overall status is set to "to_finish". If all jobs are finished or failed, the overall status is set to "finished".
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
tuple[dict[str, Any], str]: A tuple containing: |
str
|
|
tuple[dict[str, Any], str]
|
|
Source code in study_da/submit/submit_scan.py
configure_jobs(force_configure=False, dic_config_jobs=None)
Configures the jobs by modifying the tree structure and creating the run files for each job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force_configure
|
bool
|
Whether to force reconfiguration. Defaults to False. |
False
|
dic_config_jobs
|
Optional[dict[str, dict[str, Any]]]
|
A dictionary containing the configuration of the jobs. Defaults to None. |
None
|
Source code in study_da/submit/submit_scan.py
generate_run_files(dic_tree, l_jobs, dic_additional_commands_per_gen, dic_dependencies_per_gen, dic_copy_back_per_gen, name_config)
Generates run files for the specified jobs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dic_tree
|
dict
|
The dictionary tree structure. |
required |
l_jobs
|
list[str]
|
List of jobs to submit. |
required |
dic_additional_commands_per_gen
|
dict[int, str]
|
Additional commands per generation. Defaults to {}. |
required |
dic_dependencies_per_gen
|
dict[int, list[str]]
|
Dependencies per generation. Only used when doing a HTC submission. |
required |
dic_copy_back_per_gen
|
Optional[dict[int, dict[str, bool]]]
|
A dictionary containing the files to copy back per generation. Accepted keys are "parquet", "yaml", "txt", "json", "zip" and "all". |
required |
name_config
|
str
|
The name of the configuration file for the study. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The updated dictionary tree structure. |
Source code in study_da/submit/submit_scan.py
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 | |
get_all_jobs()
Retrieves all jobs from the configuration, without modifying the tree.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A dictionary containing all jobs. |
Source code in study_da/submit/submit_scan.py
keep_submit_until_done(one_generation_at_a_time=False, wait_time=30, max_try=100, dic_additional_commands_per_gen=None, dic_dependencies_per_gen=None, dic_copy_back_per_gen=None, name_config='config.yaml', force_submit=False)
Keeps submitting jobs until all jobs are finished or failed.
The following arguments are only used for HTC jobs submission: - dic_additional_commands_per_gen - dic_dependencies_per_gen - dic_copy_back_per_gen - name_config
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
one_generation_at_a_time
|
bool
|
Whether to submit one full generation at a time. Defaults to False. |
False
|
wait_time
|
float
|
The wait time between submissions in minutes. Defaults to 30. |
30
|
max_try
|
int
|
The maximum number of tries before stopping the submission. |
100
|
dic_additional_commands_per_gen
|
dict[int, str]
|
Additional commands per generation. Defaults to None. |
None
|
dic_dependencies_per_gen
|
dict[int, list[str]]
|
Dependencies per generation. Only used when doing a HTC submission. Defaults to None. |
None
|
dic_copy_back_per_gen
|
Optional[dict[int, dict[str, bool]]]
|
A dictionary containing the files to copy back per generation. Accepted keys are "parquet", "yaml", "txt", "json", "zip" and "all". Defaults to None, corresponding to copying back only "light" files, i.e. parquet, yaml and txt. |
None
|
name_config
|
str
|
The name of the configuration file for the study. Defaults to "config.yaml". |
'config.yaml'
|
force_submit
|
bool
|
If True, jobs are resubmitted even though they failed. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/submit/submit_scan.py
log_jobs_state(dic_summary_by_gen)
staticmethod
Logs the state of jobs for each generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dic_summary_by_gen
|
dict
|
A dictionary where the keys are generation numbers and the values are dictionaries summarizing job states. Each summary dictionary should contain the following keys: - 'to_submit_later': int, number of jobs left to submit later - 'running_or_queuing': int, number of jobs running or queuing - 'submitted_now': int, number of jobs submitted now - 'finished': int, number of jobs finished - 'failed': int, number of jobs failed - 'dependency_failed': int, number of jobs on hold due to failed dependencies |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in study_da/submit/submit_scan.py
reset_failed_jobs(dic_tree)
Resets the status of jobs that have failed to "to_submit".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dic_tree
|
dict[str, Any]
|
The dictionary tree structure. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: The updated dictionary tree structure. |
Source code in study_da/submit/submit_scan.py
submit(one_generation_at_a_time=False, dic_additional_commands_per_gen=None, dic_dependencies_per_gen=None, dic_copy_back_per_gen=None, name_config='config.yaml', force_submit=False)
Submits the jobs to the cluster. Note that copying back large files (e.g. json colliders) can trigger a throttling mechanism in AFS.
The following arguments are only used for HTC jobs submission: - dic_additional_commands_per_gen - dic_dependencies_per_gen - dic_copy_back_per_gen - name_config
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
one_generation_at_a_time
|
bool
|
Whether to submit one full generation at a time. Defaults to False. |
False
|
dic_additional_commands_per_gen
|
dict[int, str]
|
Additional commands per generation. Defaults to None. |
None
|
dic_dependencies_per_gen
|
dict[int, list[str]]
|
Dependencies per generation. Only used when doing a HTC submission. Defaults to None. |
None
|
dic_copy_back_per_gen
|
Optional[dict[int, dict[str, bool]]]
|
A dictionary containing the files to copy back per generation. Accepted keys are "parquet", "yaml", "txt", "json", "zip" and "all". Defaults to None, corresponding to copying back only "light" files, i.e. parquet, yaml and txt. |
None
|
name_config
|
str
|
The name of the configuration file for the study. Defaults to "config.yaml". |
'config.yaml'
|
force_submit
|
bool
|
If True, jobs are resubmitted even though they failed. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The final status of the jobs. |
Source code in study_da/submit/submit_scan.py
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 | |
aggregate_output_data(path_tree, l_group_by_parameters, function_to_aggregate=min, generation_of_interest=2, name_output='output_particles.parquet', write_output=True, path_output=None, only_keep_lost_particles=True, dic_parameters_of_interest=None, l_parameters_to_keep=None, name_template_parameters='parameters_lhc.yaml', path_template_parameters=None, force_overwrite=False)
Aggregates output data from simulation files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_tree
|
str
|
The path to the tree file. |
required |
l_group_by_parameters
|
list
|
List of parameters to group by. |
required |
function_to_aggregate
|
callable
|
Function to aggregate the grouped data. |
min
|
generation_of_interest
|
int
|
The generation of interest. Defaults to 2. |
2
|
name_output
|
str
|
The name of the output file. Defaults to "output_particles.parquet". |
'output_particles.parquet'
|
write_output
|
bool
|
Flag to indicate if the output should be written to a file. Defaults to True. |
True
|
path_output
|
str
|
The path to the output file. If not provided, the default output file will be in the study folder as 'da.parquet'. Defaults to None. |
None
|
only_keep_lost_particles
|
bool
|
Flag to indicate if only lost particles should be kept. Defaults to True. |
True
|
dic_parameters_of_interest
|
dict
|
Dictionary of parameters of interest. Defaults to None. |
None
|
l_parameters_to_keep
|
list
|
List of parameters to keep. Defaults to None. |
None
|
name_template_parameters
|
str
|
The name of the template parameters file associating each parameter to a list of keys. Defaults to "parameters_lhc.yaml", which is already contained in the study-da package, and includes the main usual parameters. |
'parameters_lhc.yaml'
|
path_template_parameters
|
str
|
The path to the template parameters file. Must be provided if a no template already contained in study-da is provided through the argument name_template_parameters. Defaults to None. |
None
|
force_overwrite
|
bool
|
Flag to indicate if the output file should be overwritten if it already exists. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: The final aggregated DataFrame. |
Source code in study_da/postprocess/postprocess.py
169 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 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 | |
create(path_config_scan='config_scan.yaml', force_overwrite=False, dic_parameter_all_gen=None, dic_parameter_all_gen_naming=None, add_prefix_to_folder_names=False)
Create a study based on the configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_config_scan
|
str
|
Path to the configuration file for the scan. Defaults to "config_scan.yaml". |
'config_scan.yaml'
|
force_overwrite
|
bool
|
Flag to force overwrite the study. Defaults to False. |
False
|
dic_parameter_all_gen
|
Optional[dict[str, dict[str, Any]]]
|
Dictionary of parameters for the scan, if not provided through the scan config. Defaults to None. |
None
|
dic_parameter_all_gen_naming
|
Optional[dict[str, dict[str, Any]]]
|
Dictionary of parameters for the naming of the scan subfolders, if not provided through the scan config. Defaults to None. |
None
|
add_prefix_to_folder_names
|
bool
|
Whether to add a prefix to the folder names. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
tuple[str, str]: The path to the tree file and the name of the main configuration file. |
Source code in study_da/study_da.py
create_single_job(name_main_configuration, name_executable_generation_1, name_executable_generation_2=None, name_executable_generation_3=None, name_study='single_job_study', force_overwrite=False)
Create a single job study (not a parametric scan) with the specified configuration and executables. Limited to three generations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name_main_configuration
|
str
|
The name of the main configuration file for the study. |
required |
name_executable_generation_1
|
str
|
The name of the executable for the first generation. |
required |
name_executable_generation_2
|
Optional[str]
|
The name of the executable for the second generation. Defaults to None. |
None
|
name_executable_generation_3
|
Optional[str]
|
The name of the executable for the third generation. Defaults to None. |
None
|
name_study
|
str
|
The name of the study. Defaults to "single_job_study". |
'single_job_study'
|
force_overwrite
|
bool
|
Whether to force overwrite existing files. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The path to the tree file. |
Source code in study_da/study_da.py
get_title_from_configuration(dataframe_data, ions=False, crossing_type=None, display_LHC_version=True, display_energy=True, display_bunch_index=True, display_CC_crossing=True, display_bunch_intensity=True, display_beta=True, display_crossing_IP_1=True, display_crossing_IP_2=True, display_crossing_IP_5=True, display_crossing_IP_8=True, display_bunch_length=True, display_polarity_IP_2_8=True, display_emittance=True, display_chromaticity=True, display_octupole_intensity=True, display_coupling=True, display_filling_scheme=True, display_horizontal_tune=None, display_vertical_tune=None, display_tune=True, display_luminosity_1=True, display_luminosity_2=True, display_luminosity_5=True, display_luminosity_8=True, display_PU_1=True, display_PU_2=True, display_PU_5=True, display_PU_8=True, display_number_of_turns=False)
Generates a title string from the configuration data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe_data
|
DataFrame
|
The dataframe containing configuration data. |
required |
ions
|
bool
|
Whether the beam is composed of ions. Defaults to False. |
False
|
crossing_type
|
str
|
The type of crossing: 'vh' or 'hv'. Defaults to None, meaning it will try to be inferred from the optics file name. Back to 'hv' if not found. |
None
|
display_betx_bety
|
bool
|
Whether to display the beta functions. Defaults to True. |
required |
display_LHC_version
|
bool
|
Whether to display the LHC version. Defaults to True. |
True
|
display_energy
|
bool
|
Whether to display the energy. Defaults to True. |
True
|
display_bunch_index
|
bool
|
Whether to display the bunch index. Defaults to True. |
True
|
display_CC_crossing
|
bool
|
Whether to display the CC crossing. Defaults to True. |
True
|
display_bunch_intensity
|
bool
|
Whether to display the bunch intensity. Defaults to True. |
True
|
display_beta
|
bool
|
Whether to display the beta function. Defaults to True. |
True
|
display_crossing_IP_1
|
bool
|
Whether to display the crossing at IP1. Defaults to True. |
True
|
display_crossing_IP_2
|
bool
|
Whether to display the crossing at IP2. Defaults to True. |
True
|
display_crossing_IP_5
|
bool
|
Whether to display the crossing at IP5. Defaults to True. |
True
|
display_crossing_IP_8
|
bool
|
Whether to display the crossing at IP8. Defaults to True. |
True
|
display_bunch_length
|
bool
|
Whether to display the bunch length. Defaults to True. |
True
|
display_polarity_IP_2_8
|
bool
|
Whether to display the polarity at IP2 and IP8. Defaults to True. |
True
|
display_emittance
|
bool
|
Whether to display the emittance. Defaults to True. |
True
|
display_chromaticity
|
bool
|
Whether to display the chromaticity. Defaults to True. |
True
|
display_octupole_intensity
|
bool
|
Whether to display the octupole intensity. Defaults to True. |
True
|
display_coupling
|
bool
|
Whether to display the coupling. Defaults to True. |
True
|
display_filling_scheme
|
bool
|
Whether to display the filling scheme. Defaults to True. |
True
|
display_horizontal_tune
|
bool
|
Whether to display the horizontal tune. Defaults to None. Takes precedence over display_tune. |
None
|
display_vertical_tune
|
bool
|
Whether to display the vertical tune. Defaults to None. Takes precedence over display_tune. |
None
|
display_tune
|
bool
|
Whether to display the tune. Defaults to True. |
True
|
display_luminosity_1
|
bool
|
Whether to display the luminosity at IP1. Defaults to True. |
True
|
display_luminosity_2
|
bool
|
Whether to display the luminosity at IP2. Defaults to True. |
True
|
display_luminosity_5
|
bool
|
Whether to display the luminosity at IP5. Defaults to True. |
True
|
display_luminosity_8
|
bool
|
Whether to display the luminosity at IP8. Defaults to True. |
True
|
display_PU_1
|
bool
|
Whether to display the PU at IP1. Defaults to True. |
True
|
display_PU_2
|
bool
|
Whether to display the PU at IP2. Defaults to True. |
True
|
display_PU_5
|
bool
|
Whether to display the PU at IP5. Defaults to True. |
True
|
display_PU_8
|
bool
|
Whether to display the PU at IP8. Defaults to True. |
True
|
display_number_of_turns
|
bool
|
Whether to display the number of turns. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The generated title string. |
Source code in study_da/plot/build_title.py
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 | |
plot_3D(dataframe_data, x_variable, y_variable, z_variable, color_variable, xlabel=None, ylabel=None, z_label=None, title='', vmin=4.5, vmax=7.5, surface_count=30, opacity=0.2, figsize=(1000, 1000), colormap='RdBu', colorbar_title_text='Minimum DA (σ)', display_colormap=False, output_path='output.png', output_path_html='output.html', display_plot=True, dark_theme=False)
Plots a 3D volume rendering from the given dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe_data
|
DataFrame
|
The dataframe containing the data to plot. |
required |
x_variable
|
str
|
The variable to plot on the x-axis. |
required |
y_variable
|
str
|
The variable to plot on the y-axis. |
required |
z_variable
|
str
|
The variable to plot on the z-axis. |
required |
color_variable
|
str
|
The variable to use for the color scale. |
required |
xlabel
|
Optional[str]
|
The label for the x-axis. Defaults to None. |
None
|
ylabel
|
Optional[str]
|
The label for the y-axis. Defaults to None. |
None
|
z_label
|
Optional[str]
|
The label for the z-axis. Defaults to None. |
None
|
title
|
str
|
The title of the plot. Defaults to "". |
''
|
vmin
|
float
|
The minimum value for the color scale. Defaults to 4.5. |
4.5
|
vmax
|
float
|
The maximum value for the color scale. Defaults to 7.5. |
7.5
|
surface_count
|
int
|
The number of surfaces for volume rendering. Defaults to 30. |
30
|
opacity
|
float
|
The opacity of the volume rendering. Defaults to 0.2. |
0.2
|
figsize
|
tuple[float, float]
|
The size of the figure. Defaults to (1000, 1000). |
(1000, 1000)
|
colormap
|
str
|
The colormap to use. Defaults to "RdBu". |
'RdBu'
|
colorbar_title_text
|
str
|
The label for the colorbar. Defaults to "Minimum DA (σ)". |
'Minimum DA (σ)'
|
display_colormap
|
bool
|
Whether to display the colormap. Defaults to False. |
False
|
output_path
|
str
|
The path to save the plot image. Defaults to "output.png". |
'output.png'
|
output_path_html
|
str
|
The path to save the plot HTML. Defaults to "output.html". |
'output.html'
|
display_plot
|
bool
|
Whether to display the plot. Defaults to True. |
True
|
dark_theme
|
bool
|
Whether to use a dark theme. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
Any
|
go.Figure: The plotly figure object. |
Source code in study_da/plot/plot_study.py
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 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 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 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 | |
plot_heatmap(dataframe_data, horizontal_variable, vertical_variable, color_variable, link=None, position_qr='top-right', plot_contours=True, xlabel=None, ylabel=None, tick_interval=2, round_xticks=None, round_yticks=None, symmetric_missing=False, mask_lower_triangle=False, mask_upper_triangle=False, plot_diagonal_lines=True, shift_diagonal_lines=1, xaxis_ticks_on_top=True, title='', vmin=4.5, vmax=7.5, k_masking=-1, green_contour=6.0, min_level_contours=1, max_level_contours=15, delta_levels_contours=0.5, figsize=None, label_cbar='Minimum DA (' + '$\\sigma$' + ')', colormap='coolwarm_r', style='ggplot', output_path='output.png', display_plot=True, latex_fonts=True, vectorize=False, fill_missing_value_with=None, dpi=300)
Plots a heatmap from the given dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe_data
|
DataFrame
|
The dataframe containing the data to plot. |
required |
horizontal_variable
|
str
|
The variable to plot on the horizontal axis. |
required |
vertical_variable
|
str
|
The variable to plot on the vertical axis. |
required |
color_variable
|
str
|
The variable to use for the color scale. |
required |
link
|
Optional[str]
|
A link to encode in a QR code. Defaults to None. |
None
|
plot_contours
|
bool
|
Whether to plot contours. Defaults to True. |
True
|
xlabel
|
Optional[str]
|
The label for the x-axis. Defaults to None. |
None
|
ylabel
|
Optional[str]
|
The label for the y-axis. Defaults to None. |
None
|
tick_interval
|
int
|
The interval for the ticks. Defaults to 2. |
2
|
round_xticks
|
Optional[int]
|
The number of decimal places to round the x-ticks to. Defaults to None. |
None
|
round_yticks
|
Optional[int]
|
The number of decimal places to round the y-ticks to. Defaults to None. |
None
|
symmetric_missing
|
bool
|
Whether to make the matrix symmetric by replacing the lower triangle with the upper triangle. Defaults to False. |
False
|
mask_lower_triangle
|
bool
|
Whether to mask the lower triangle. Defaults to False. |
False
|
mask_upper_triangle
|
bool
|
Whether to mask the upper triangle. Defaults to False. |
False
|
plot_diagonal_lines
|
bool
|
Whether to plot diagonal lines. Defaults to True. |
True
|
shift_diagonal_lines
|
int
|
The shift for the diagonal lines. Defaults to 1. |
1
|
xaxis_ticks_on_top
|
bool
|
Whether to place the x-axis ticks on top. Defaults to True. |
True
|
title
|
str
|
The title of the plot. Defaults to "". |
''
|
vmin
|
float
|
The minimum value for the color scale. Defaults to 4.5. |
4.5
|
vmax
|
float
|
The maximum value for the color scale. Defaults to 7.5. |
7.5
|
k_masking
|
int
|
The k parameter for masking. Defaults to -1. |
-1
|
green_contour
|
Optional[float]
|
The value for the green contour line. Defaults to 6.0. |
6.0
|
min_level_contours
|
float
|
The minimum level for the contours. Defaults to 1. |
1
|
max_level_contours
|
float
|
The maximum level for the contours. Defaults to 15. |
15
|
delta_levels_contours
|
float
|
The delta between contour levels. Defaults to 0.5. |
0.5
|
figsize
|
Optional[tuple[float, float]]
|
The size of the figure. Defaults to None. |
None
|
label_cbar
|
str
|
The label for the colorbar. Defaults to "Minimum DA ($\sigma$)". |
'Minimum DA (' + '$\\sigma$' + ')'
|
colormap
|
str
|
The colormap to use. Defaults to "coolwarm_r". |
'coolwarm_r'
|
style
|
str
|
The style to use for the plot. Defaults to "ggplot". |
'ggplot'
|
output_path
|
str
|
The path to save the plot. Defaults to "output.pdf". |
'output.png'
|
display_plot
|
bool
|
Whether to display the plot. Defaults to True. |
True
|
latex_fonts
|
bool
|
Whether to use LaTeX fonts. Defaults to True. |
True
|
vectorize
|
bool
|
Whether to vectorize the plot. Defaults to False. |
False
|
fill_missing_value_with
|
Optional[str | float]
|
The value to fill missing values with. Can be a number or 'interpolate'. Defaults to None. |
None
|
dpi
|
int
|
The DPI for the plot. Defaults to 300. |
300
|
Returns:
| Type | Description |
|---|---|
tuple[Figure, Axes]
|
tuple[plt.Figure, plt.Axes]: The figure and axes of the plot. |
Source code in study_da/plot/plot_study.py
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 | |