From 39049bdbacac0fd26ede4e91415afec8d7412a82 Mon Sep 17 00:00:00 2001 From: Abhaas Goyal Date: Sun, 21 Jan 2024 15:59:47 +1100 Subject: [PATCH] Clean up parsing optional config data --- benchcab/benchcab.py | 4 ++-- benchcab/config.py | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/benchcab/benchcab.py b/benchcab/benchcab.py index b519af2e..b77090a2 100644 --- a/benchcab/benchcab.py +++ b/benchcab/benchcab.py @@ -107,7 +107,7 @@ def _get_models(self, config: dict) -> list[Model]: for id, sub_config in enumerate(config["realisations"]): repo = create_repo( spec=sub_config.pop("repo"), - path=internal.SRC_DIR / config["name"], + path=internal.SRC_DIR / sub_config["name"], ) self._models.append(Model(repo=repo, model_id=id, **sub_config)) return self._models @@ -147,10 +147,10 @@ def fluxsite_submit_job( project=config["project"], config_path=config_path, modules=config["modules"], + pbs_config=config["fluxsite"]["pbs"], verbose=verbose, skip_bitwise_cmp="fluxsite-bitwise-cmp" in skip, benchcab_path=str(self.benchcab_exe_path), - pbs_config=config["fluxsite"]["pbs"], ) file.write(contents) diff --git a/benchcab/config.py b/benchcab/config.py index cc0c7bcd..6e7d7fbd 100644 --- a/benchcab/config.py +++ b/benchcab/config.py @@ -68,19 +68,17 @@ def validate_config(config: dict) -> bool: def read_optional_data(config: dict): - config["name"] = config.get("name", Path(".")) + if "realisations" in config: + for r in config["realisations"]: + r["name"] = r.get("name", str(internal.SRC_DIR)) + config["science_configurations"] = config.get("science_configurations", internal.DEFAULT_SCIENCE_CONFIGURATIONS) config["fluxsite"] = config.get("fluxsite", {}) + + config["fluxsite"]["multiprocess"] = config["fluxsite"].get("multiprocess", internal.FLUXSITE_DEFAULT_MULTIPROCESS) config["fluxsite"]["experiment"] = config["fluxsite"].get("experiment", internal.FLUXSITE_DEFAULT_EXPERIMENT) - config["fluxsite"]["pbs"] = config["fluxsite"].get("pbs", {}) - - pbs_config = config["fluxsite"]["pbs"] - pbs_config_params = ["mem", "ncpus", "storage", "walltime"] - for pcp in pbs_config_params: - pbs_config[pcp] = pbs_config.get(pcp, internal.FLUXSITE_DEFAULT_PBS[pcp]) - - pbs_config["multiprocess"] = internal.FLUXSITE_DEFAULT_MULTIPROCESS + config["fluxsite"]["pbs"] = config["fluxsite"].get("pbs", internal.FLUXSITE_DEFAULT_PBS) def read_config(config_path: str) -> dict: """Reads the config file and returns a dictionary containing the configurations.