Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/common/src/weathergen/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def load_model_config(run_id: str, epoch: int | None, model_path: str | None) ->

config = OmegaConf.create(json.loads(json_str))

return _check_logging(config)
return _apply_fixes(config)


def _get_model_config_file_name(run_id: str, epoch: int | None):
Expand All @@ -100,6 +100,7 @@ def _get_model_config_file_name(run_id: str, epoch: int | None):
epoch_str = f"_epoch{epoch:05d}"
return f"model_{run_id}{epoch_str}.json"


def get_model_results(run_id: str, epoch: int, rank: int) -> Path:
"""
Get the path to the model results zarr store from a given run_id and epoch.
Expand All @@ -110,6 +111,7 @@ def get_model_results(run_id: str, epoch: int, rank: int) -> Path:
raise FileNotFoundError(f"Zarr file {zarr_path} does not exist or is not a directory.")
return zarr_path


def _apply_fixes(config: Config) -> Config:
"""
Apply fixes to maintain a best effort backward combatibility.
Expand All @@ -129,12 +131,13 @@ def _check_logging(config: Config) -> Config:
"""
config = config.copy()
if config.get("train_log_freq") is None: # TODO remove this for next version
config.train_log_freq = OmegaConf.construct(
config.train_log_freq = OmegaConf.create(
{"checkpoint": 250, "terminal": 10, "metrics": config.train_log.log_interval}
)

return config


def load_config(
private_home: Path | None,
from_run_id: str | None,
Expand Down
Loading