Skip to content

Commit

Permalink
Merge pull request #43 from metno/42-check-that-configs-validate-in-u…
Browse files Browse the repository at this point in the history
…nit-tests

Add unit test for config validation
  • Loading branch information
tnipen authored Feb 27, 2025
2 parents 107bfea + 97fd416 commit 6404a6b
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
3 changes: 1 addition & 2 deletions bris/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@
"type": "object",
"properties": {
"dataset": {
"description": "Anemoi datasets open_dataset recipe, dictionary",
"type": "object"
"description": "Anemoi datasets open_dataset recipe, dictionary"
},
"variable": {
"description": "Variable name",
Expand Down
70 changes: 70 additions & 0 deletions config/working_example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
defaults:
- override hydra/job_logging: none
- override hydra/hydra_logging: none
- _self_

start_date: 2023-05-31T18:00:00
end_date: 2023-06-01T12:00:00 #2024-06-01T01:00:00

checkpoint_path: /pfs/lustrep4/scratch/project_465001383/aifs/experiments/reference/o96_pretrain/checkpoint/3fb85b72ba9647d5ae4fe86ce1b5a885/inference-last.ckpt

leadtimes: 12
timestep: 6h
frequency: 6h

deterministic: True

# If the user wants to release GPU cache and memory
# This option releases unused cached/memory used by torch
release_cache: False

dataloader:
batch_size: 1
prefetch_factor: 2
num_workers: 1
pin_memory: True

read_group_size: 1 #Do not change this, not implemented properly

predict:
dataset: ${dataset}
drop: ['cp', 'u_600', 'v_600', 'z_600', 't_600', 'q_600', 'w_600', 'longitude', 'latitude']
start: ${start_date}
end: ${end_date}
frequency: ${frequency}
reorder: ${reorder}

datamodule:
_target_: bris.data.dataset.NativeGridDataset #anemoi.training.data.dataset.ZipDataset
_convert_: all

hardware:
num_gpus_per_node: 8
num_gpus_per_model: 8
num_nodes: 1

dataset: aifs-od-an-oper-0001-mars-n320-2023-2024-6h-v2.zarr
workdir: test


model:
_target_: bris.model.BrisPredictor
_convert_: all

routing:
- decoder_index: 0
domain_index: 0
outputs:
- netcdf:
filename_pattern: /pfs/lustrep4/scratch/project_465001383/haugenha/anemoi-training-ref-updated/run-anemoi/lumi/predictions/n320_pred_%Y%m%dT%HZ.nc
variables: [2t, msl]
- verif:
filename: /pfs/lustrep4/scratch/project_465001383/haugenha/anemoi-training-ref-updated/run-anemoi/lumi/verif/2t/n320_at_ref.nc
variable: 2t
units: degC
obs_sources:
- verif:
filename: /pfs/lustrep4/scratch/project_465001383/aifs/old_project_misc/verification/202306_202405/t2m/AIFS_legendary_gnome_roll4.nc
- anemoidataset:
dataset: test.zarr
variable: 2t
16 changes: 16 additions & 0 deletions tests/test_configs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os

import bris.utils


def test_1():
filenames = ["working_example.yaml"]
for filename in filenames:
full_filename = (
os.path.dirname(os.path.abspath(__file__)) + "/../config/" + filename
)
bris.utils.validate(full_filename)


if __name__ == "__main__":
test_1()

0 comments on commit 6404a6b

Please sign in to comment.