Skip to content

Commit

Permalink
Better check of config arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
b8raoult committed Jun 28, 2024
1 parent 25e552e commit ba949f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/anemoi/training/commands/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ def run(self, args):
for config in args.config:
if override_regex.match(config):
overrides.append(config)
else:
elif config.endswith(".yaml") or config.endswith(".yml"):
configs.append(config)
else:
raise ValueError(f"Invalid config '{config}'. It must be a yaml file or an override")

hydra.initialize(config_path="../config", version_base=None)

cfg = hydra.compose(config_name="config", overrides=overrides)
cfg = hydra.compose(config_name="config") # , overrides=overrides)
print(cfg)

# Add user config
user_config = config_path("training.yaml")
Expand All @@ -82,6 +85,7 @@ def run(self, args):
cfg = OmegaConf.merge(cfg, OmegaConf.load(config))

# We need to reapply the overrides
# This does not support overrides with a prefix
cfg = OmegaConf.merge(cfg, OmegaConf.from_dotlist(overrides))

print(json.dumps(OmegaConf.to_container(cfg, resolve=True), indent=4))
Expand Down
6 changes: 4 additions & 2 deletions src/anemoi/training/config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
defaults:
- _self_
- _self_

model:
num_channels: 128

dataloader:
limit_batches:
training: 100
validation: 100

training:
max_epochs: 3

token:
mflow: None
mlflow: null

0 comments on commit ba949f7

Please sign in to comment.