|
39 | 39 | from importlib.resources import files as read_files |
40 | 40 | from pathlib import Path |
41 | 41 | from time import sleep |
42 | | -from typing import Any, Optional, Union, TYPE_CHECKING |
| 42 | +from typing import Any, Optional, Union |
43 | 43 |
|
44 | 44 | from bscearth.utils.date import date2str |
45 | 45 | from portalocker import Lock |
46 | 46 | from portalocker.exceptions import BaseLockException |
47 | | -from pycparser.c_ast import Return |
48 | 47 | from pyparsing import nestedExpr |
49 | 48 | from ruamel.yaml import YAML |
50 | 49 |
|
|
81 | 80 | from autosubmit.platforms.paramiko_submitter import ParamikoSubmitter |
82 | 81 | from autosubmit.platforms.platform import Platform |
83 | 82 |
|
84 | | - |
85 | 83 | dialog = None |
86 | 84 |
|
87 | 85 | """Main module for autosubmit. Only contains an interface class to all functionality implemented on autosubmit.""" |
@@ -492,14 +490,15 @@ def parse_args() -> tuple[int, Optional[argparse.Namespace]]: |
492 | 490 | help="Select the database backend to use. Default is sqlite.", |
493 | 491 | ) |
494 | 492 | subparser.add_argument( |
495 | | - "--database-conn-url", default=None, help="Database connection URL string. Required for postgres backend." |
| 493 | + "--database-conn-url", default=None, |
| 494 | + help="Database connection URL string. Required for postgres backend." |
496 | 495 | ) |
497 | 496 | subparser.add_argument( |
498 | 497 | "-db", |
499 | 498 | "--databasepath", |
500 | 499 | default=None, |
501 | 500 | help="path to SQLite database. If not supplied, " |
502 | | - "it will prompt for it. Required for SQLite backend.", |
| 501 | + "it will prompt for it. Required for SQLite backend.", |
503 | 502 | ) |
504 | 503 | subparser.add_argument( |
505 | 504 | '-dbf', '--databasefilename', default=None, help='database filename') |
@@ -888,12 +887,12 @@ def _init_logs(args, console_level='INFO', log_level='DEBUG', expid='None'): |
888 | 887 | if not permissions: |
889 | 888 | raise AutosubmitCritical( |
890 | 889 | f'Experiments database {BasicConfig.DB_PATH} not readable. Please check permissions.' |
891 | | - , 7007) |
| 890 | + , 7007) |
892 | 891 | permissions = os.access(BasicConfig.DB_PATH, os.W_OK) # Check for write access |
893 | 892 | if not permissions: |
894 | 893 | raise AutosubmitCritical( |
895 | 894 | f'Experiments database {BasicConfig.DB_PATH} not writable. Please check permissions.' |
896 | | - , 7007) |
| 895 | + , 7007) |
897 | 896 |
|
898 | 897 | expid_less = ["expid", "describe", "testcase", "install", "-v", |
899 | 898 | "readme", "changelog", "configure", "unarchive", |
@@ -1243,7 +1242,6 @@ def _perform_deletion(experiment_path: Path, structure_db_path: Path, job_data_d |
1243 | 1242 | except BaseException as e: |
1244 | 1243 | error_message += f"Cannot delete directory: {e}\n" |
1245 | 1244 |
|
1246 | | - |
1247 | 1245 | if is_sqlite: |
1248 | 1246 | Log.info("Removing Structure db...") |
1249 | 1247 | try: |
@@ -2197,7 +2195,7 @@ def prepare_run( |
2197 | 2195 | except IOError as e: |
2198 | 2196 | raise AutosubmitError("job_packages not found", 6016, str(e)) |
2199 | 2197 | # Check if the user wants to continue using wrappers and loads the appropriate info. |
2200 | | - if as_conf.experiment_data.get("WRAPPERS",None) is not None: |
| 2198 | + if as_conf.experiment_data.get("WRAPPERS", None) is not None: |
2201 | 2199 | if BasicConfig.DATABASE_BACKEND == 'sqlite': |
2202 | 2200 | os.chmod(os.path.join(BasicConfig.LOCAL_ROOT_DIR, |
2203 | 2201 | expid, "pkl", "job_packages_" + expid + ".db"), 0o644) |
@@ -2637,21 +2635,24 @@ def restore_platforms(platforms_to_test, mail_notify=False, as_conf=None, expid= |
2637 | 2635 | if platform_to_test.check_remote_permissions(): |
2638 | 2636 | Log.result(f"[{platform_to_test.name}] Correct user privileges for host {platform_to_test.host}") |
2639 | 2637 | else: |
2640 | | - platform_issues += (f"\n[{platform_to_test.name}] has configuration issues.\n Check that the connection is" |
2641 | | - f" passwd-less.(ssh {platform_to_test.user}@{platform_to_test.host})\n Check the parameters that" |
2642 | | - f" build the root_path are correct:{{scratch_dir/project/user}} =" |
2643 | | - f" {{{platform_to_test.scratch}/{platform_to_test.project}/{platform_to_test.user}}}") |
| 2638 | + platform_issues += ( |
| 2639 | + f"\n[{platform_to_test.name}] has configuration issues.\n Check that the connection is" |
| 2640 | + f" passwd-less.(ssh {platform_to_test.user}@{platform_to_test.host})\n Check the parameters that" |
| 2641 | + f" build the root_path are correct:{{scratch_dir/project/user}} =" |
| 2642 | + f" {{{platform_to_test.scratch}/{platform_to_test.project}/{platform_to_test.user}}}") |
2644 | 2643 | issues += platform_issues |
2645 | 2644 | if platform_issues == "": |
2646 | 2645 |
|
2647 | | - Log.printlog(f"[{platform_to_test.name}] Connection successful to host {platform_to_test.host}", Log.RESULT) |
| 2646 | + Log.printlog(f"[{platform_to_test.name}] Connection successful to host {platform_to_test.host}", |
| 2647 | + Log.RESULT) |
2648 | 2648 | else: |
2649 | 2649 | if platform_to_test.connected: |
2650 | 2650 | platform_to_test.connected = False |
2651 | 2651 | Log.printlog(f"[{platform_to_test.name}] Connection successful to host {platform_to_test.host}, " |
2652 | 2652 | f"however there are issues with %HPCROOT%", Log.WARNING) |
2653 | 2653 | else: |
2654 | | - Log.printlog(f"[{platform_to_test.name}] Connection failed to host {platform_to_test.host}", Log.WARNING) |
| 2654 | + Log.printlog(f"[{platform_to_test.name}] Connection failed to host {platform_to_test.host}", |
| 2655 | + Log.WARNING) |
2655 | 2656 | if issues != "": |
2656 | 2657 | if ssh_config_issues.find(private_key_error[:-2]) != -1: |
2657 | 2658 | raise AutosubmitCritical("Private key is encrypted, Autosubmit does not run in " |
@@ -2855,7 +2856,8 @@ def monitor(expid: str, file_format: str, lst: str, filter_chunks: str, filter_s |
2855 | 2856 | packages_persistence = JobPackagePersistence(expid) |
2856 | 2857 | # Permissions |
2857 | 2858 | if BasicConfig.DATABASE_BACKEND == 'sqlite': |
2858 | | - os.chmod(os.path.join(BasicConfig.LOCAL_ROOT_DIR, expid, "pkl", "job_packages_" + expid + ".db"), 0o644) |
| 2859 | + os.chmod(os.path.join(BasicConfig.LOCAL_ROOT_DIR, expid, "pkl", "job_packages_" + expid + ".db"), |
| 2860 | + 0o644) |
2859 | 2861 | # Database modification |
2860 | 2862 | packages_persistence.reset_table(True) |
2861 | 2863 | # Load another job_list to go through that goes through the jobs, but we want to monitor the other one |
@@ -3528,18 +3530,18 @@ def describe(input_experiment_list="*", get_from_user=""): |
3528 | 3530 |
|
3529 | 3531 | @staticmethod |
3530 | 3532 | def configure( |
3531 | | - advanced, |
3532 | | - database_path, |
3533 | | - database_filename, |
3534 | | - local_root_path, |
3535 | | - platforms_conf_path, |
3536 | | - jobs_conf_path, |
3537 | | - smtp_hostname, |
3538 | | - mail_from, |
3539 | | - machine: bool, |
3540 | | - local: bool, |
3541 | | - database_backend: str = "sqlite", |
3542 | | - database_conn_url: str = "", |
| 3533 | + advanced, |
| 3534 | + database_path, |
| 3535 | + database_filename, |
| 3536 | + local_root_path, |
| 3537 | + platforms_conf_path, |
| 3538 | + jobs_conf_path, |
| 3539 | + smtp_hostname, |
| 3540 | + mail_from, |
| 3541 | + machine: bool, |
| 3542 | + local: bool, |
| 3543 | + database_backend: str = "sqlite", |
| 3544 | + database_conn_url: str = "", |
3543 | 3545 | ): |
3544 | 3546 | """ |
3545 | 3547 | Configure several paths for autosubmit: database, local root and others. Can be configured at system, |
@@ -4137,7 +4139,8 @@ def pkl_fix(expid: str, force: bool = False) -> int: |
4137 | 4139 | :rtype: |
4138 | 4140 | """ |
4139 | 4141 | if BasicConfig.DATABASE_BACKEND != 'sqlite': |
4140 | | - raise AutosubmitCritical("This operation is only available when Autosubmit database backend is set to sqlite", 7000) |
| 4142 | + raise AutosubmitCritical( |
| 4143 | + "This operation is only available when Autosubmit database backend is set to sqlite", 7000) |
4141 | 4144 | exp_path = os.path.join(BasicConfig.LOCAL_ROOT_DIR, expid) |
4142 | 4145 | tmp_path = os.path.join(exp_path, BasicConfig.LOCAL_TMP_DIR) |
4143 | 4146 | pkl_folder_path = os.path.join(exp_path, "pkl") |
@@ -4608,7 +4611,7 @@ def create(expid: str, noplot: bool, hide: bool, output='pdf', group_by: Optiona |
4608 | 4611 | as_conf.check_conf_files(running_time=False, force_load=True, no_log=False) |
4609 | 4612 | if len(as_conf.experiment_data.get("JOBS", |
4610 | 4613 | {})) == 0 and "CUSTOM_CONFIG" in as_conf.experiment_data.get( |
4611 | | - "DEFAULT", {}): |
| 4614 | + "DEFAULT", {}): |
4612 | 4615 | raise AutosubmitCritical( |
4613 | 4616 | f'Job list is empty\nCheck if there are YML files in {as_conf.experiment_data.get("DEFAULT", "").get("CUSTOM_CONFIG", "")}', |
4614 | 4617 | code=7015) |
@@ -5221,7 +5224,7 @@ def _apply_ftc(job_list: JobList, filter_type_chunk_split: str) -> list[Job]: |
5221 | 5224 | final_splits.append(str(split)) |
5222 | 5225 | splits = final_splits |
5223 | 5226 | jobs_filtered = [j for j in working_list if j.section == section and ( |
5224 | | - j.split is None or splits[0] == "ANY" or str(j.split) in splits)] |
| 5227 | + j.split is None or splits[0] == "ANY" or str(j.split) in splits)] |
5225 | 5228 | # Go through start dates |
5226 | 5229 | for starting_date in deserialized_json['sds']: |
5227 | 5230 | date = starting_date['sd'] |
@@ -5497,7 +5500,7 @@ def set_status(expid: str, noplot: bool, save: bool, final: str, filter_list: st |
5497 | 5500 | packages_persistence = JobPackagePersistence(expid) |
5498 | 5501 | if BasicConfig.DATABASE_BACKEND == 'sqlite': |
5499 | 5502 | os.chmod(os.path.join(BasicConfig.LOCAL_ROOT_DIR, |
5500 | | - expid, "pkl", "job_packages_" + expid + ".db"), 0o775) |
| 5503 | + expid, "pkl", "job_packages_" + expid + ".db"), 0o775) |
5501 | 5504 | packages_persistence.reset_table(True) |
5502 | 5505 | job_list_wr = Autosubmit.load_job_list(expid, as_conf, monitor=True, new=False) |
5503 | 5506 |
|
@@ -5720,7 +5723,9 @@ def _get_job_list_persistence(expid, as_conf) -> JobListPersistence: |
5720 | 5723 | raise AutosubmitCritical('Storage type not known', 7014) |
5721 | 5724 |
|
5722 | 5725 | @staticmethod |
5723 | | - def testcase(description, chunks=None, member=None, start_date=None, hpc=None, copy_id=None, minimal_configuration=False, git_repo=None, git_branch=None, git_as_conf=None, use_local_minimal=False): |
| 5726 | + def testcase(description, chunks=None, member=None, start_date=None, hpc=None, copy_id=None, |
| 5727 | + minimal_configuration=False, git_repo=None, git_branch=None, git_as_conf=None, |
| 5728 | + use_local_minimal=False): |
5724 | 5729 | """ |
5725 | 5730 | Method to conduct a test for a given experiment. It creates a new experiment for a given experiment with a |
5726 | 5731 | given number of chunks with a random start date and a random member to be run on a random HPC. |
|
0 commit comments