From 463aa549ff121770faa1ea9221bf14d635dc1f6d Mon Sep 17 00:00:00 2001 From: Thomas Kluyver <thomas.kluyver@xfel.eu> Date: Fri, 11 Oct 2024 17:12:57 +0200 Subject: [PATCH] --detector option to select detector type --- src/xfel_calibrate/validate_nbs_config.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/xfel_calibrate/validate_nbs_config.py b/src/xfel_calibrate/validate_nbs_config.py index 502cd4c7f..67881e2a3 100644 --- a/src/xfel_calibrate/validate_nbs_config.py +++ b/src/xfel_calibrate/validate_nbs_config.py @@ -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) -- GitLab