Skip to content

Commit

Permalink
Clean up parsing optional config data
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaasgoyal committed Jan 21, 2024
1 parent 3f59fe3 commit 39049bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions benchcab/benchcab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
16 changes: 7 additions & 9 deletions benchcab/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 39049bd

Please sign in to comment.