Skip to content

Commit 3736f61

Browse files
mlubejMatic Lubej
and
Matic Lubej
authored
Add config validation tests (#363)
* force cache update if updates available * try without the cache * fix configs * revert CI/CD * add config validation tests * includi zipmap pipeline and fix chain pipeline handling --------- Co-authored-by: Matic Lubej <[email protected]>
1 parent bb972b3 commit 3736f61

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

tests/test_config_files/export_maps/export_maps_data.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"maps": "maps/BANDS-S2-L1C"
77
}
88
},
9-
"input_folder_key": "data_2019",
9+
"input_folder_key": "data",
1010
"output_folder_key": "maps",
1111
"feature": ["data", "BANDS-S2-L1C"],
1212
"map_name": "result.tiff",

tests/test_config_files/export_maps/export_maps_mask.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"maps": "maps/CLM"
77
}
88
},
9-
"input_folder_key": "data_2019",
9+
"input_folder_key": "data",
1010
"output_folder_key": "maps",
1111
"feature": ["mask", "CLM"],
1212
"map_dtype": "uint16",

tests/test_config_files/export_maps/export_maps_mask_local_copy.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"maps": "maps/CLM"
77
}
88
},
9-
"input_folder_key": "data_2019",
9+
"input_folder_key": "data",
1010
"output_folder_key": "maps",
1111
"feature": ["mask", "CLM"],
1212
"map_dtype": "uint16",

tests/test_configs.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import os
2+
import re
3+
from glob import glob
4+
5+
import pytest
6+
7+
import eogrow
8+
from eogrow.core.config import collect_configs_from_path, interpret_config_from_dict
9+
from eogrow.utils.meta import load_pipeline_class
10+
11+
IGNORED_FOLDERS = ["other"]
12+
CONFIG_REGEX = re.compile(r"^(?!global_).*\.json$")
13+
14+
15+
def pytest_generate_tests(metafunc):
16+
files = glob(os.path.join(eogrow.__path__[0], "..", "tests", "test_config_files", "**", "*.json"), recursive=True)
17+
files = [conf_path for conf_path in files if CONFIG_REGEX.match(os.path.split(conf_path)[-1])]
18+
files = [conf_path for conf_path in files if not any(folder in conf_path for folder in IGNORED_FOLDERS)]
19+
metafunc.parametrize("config_file", files, ids=[path.split("test_config_files/")[-1] for path in files])
20+
21+
22+
def test_validate_configs(config_file):
23+
crude_config = collect_configs_from_path(config_file)
24+
if isinstance(crude_config, list):
25+
crude_configs = [conf["pipeline_config"] for conf in crude_config]
26+
else:
27+
crude_configs = [crude_config]
28+
29+
for crude_config in crude_configs:
30+
pipeline = crude_config.get("pipeline")
31+
if pipeline is None:
32+
pytest.skip(f"Config with pipeline {pipeline} will be ignored. Skipping.")
33+
34+
config = interpret_config_from_dict(crude_config)
35+
load_pipeline_class(config).Schema.parse_obj(config)

0 commit comments

Comments
 (0)