-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprepare_testdata.py
More file actions
64 lines (44 loc) · 1.57 KB
/
Copy pathprepare_testdata.py
File metadata and controls
64 lines (44 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from __future__ import annotations
import argparse
from pathlib import Path
from typing import Any
import yaml
from tests.regression.cases import discover_cases
from tests.regression.helpers import (
_abspathify_config_paths,
ensure_testdata_for_system,
)
def unwrap_case(case_or_param: Any) -> Any:
if hasattr(case_or_param, "values"):
values = case_or_param.values
if values:
return values[0]
return case_or_param
def required_paths_for_case(case: Any) -> list[Path]:
raw = yaml.safe_load(case.config_path.read_text())
cooked = _abspathify_config_paths(raw, base_dir=case.config_path.parent)
required: list[Path] = []
run1 = cooked.get("run1")
if isinstance(run1, dict):
ff = run1.get("force_file")
if isinstance(ff, str) and ff:
required.append(Path(ff))
for p in run1.get("top_traj_file") or []:
if isinstance(p, str) and p:
required.append(Path(p))
return required
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--system", action="append", default=None)
args = parser.parse_args()
selected = set(args.system or [])
for case_or_param in discover_cases():
case = unwrap_case(case_or_param)
if selected and case.system not in selected:
continue
required = required_paths_for_case(case)
if required:
ensure_testdata_for_system(case.system, required_paths=required)
print("Regression test data prepared.")
if __name__ == "__main__":
main()