Skip to content
Snippets Groups Projects
Commit 463aa549 authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

--detector option to select detector type

parent dfaf6d84
No related branches found
No related tags found
1 merge request!1076Script to validate YAML config against notebooks
......@@ -46,7 +46,7 @@ n_probs = 0
def config_problem(problem, detail, file, key):
global n_probs
n_probs += 1
print(f"{problem}\n {detail}\n file: {file}\n key: {'/'.join(key)}")
print(f"{problem}\n {detail}\n file: {file}\n key: {'/'.join(key)}\n")
def bad_list_element_types(value, param: nbparameterise.Parameter):
......@@ -94,7 +94,7 @@ def like_type(value, param_type):
return False
def check_yaml_file(path: Path, config_dir: Path, nb_params):
def check_yaml_file(path: Path, config_dir: Path, nb_params, detectors):
rel_path = path.relative_to(config_dir)
with path.open('r') as f:
cfg = yaml.safe_load(f)
......@@ -124,6 +124,9 @@ def check_yaml_file(path: Path, config_dir: Path, nb_params):
)
continue
if detectors and (det not in detectors):
continue
try:
det_params = nb_params[det][action.upper()]
except KeyError:
......@@ -162,6 +165,7 @@ def check_yaml_file(path: Path, config_dir: Path, nb_params):
def main(argv=None):
ap = argparse.ArgumentParser()
ap.add_argument('--config-dir', type=Path, default="~/calibration_config/")
ap.add_argument('--detector', choices=notebooks.keys(), action='append')
args = ap.parse_args(argv)
config_dir = args.config_dir.expanduser()
......@@ -174,9 +178,9 @@ def main(argv=None):
print(f"Checking {len(files)} files in {config_dir}...\n")
for file in files:
check_yaml_file(file, config_dir, nb_params)
check_yaml_file(file, config_dir, nb_params, detectors=args.detector)
print(f"\n{n_probs} config issues found")
print(f"{n_probs} config issues found")
sys.exit(1 if n_probs else 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment