diff --git a/tests/test_update_config.py b/tests/test_update_config.py index e06bc052448d35800380f3a80f9280fe23ba8b4a..7a4c79965051b5a31847ca9c02875fd08eaf1252 100644 --- a/tests/test_update_config.py +++ b/tests/test_update_config.py @@ -84,27 +84,30 @@ def test_main(capsys): EXPECTED_CONF = [ { - 'force-hg-if-below': {'typ': int}, - 'rel-gain': {'typ': bool}, - 'xray-gain': {'typ': bool}, - 'blc-noise': {'typ': bool}, - 'blc-set-min': {'typ': bool}, - 'dont-zero-nans': {'typ': bool}, - 'dont-zero-orange': {'typ': bool}, - 'max-pulses': {'typ': list, + 'force-hg-if-below': {'type': int}, + 'rel-gain': {'type': bool}, + 'xray-gain': {'type': bool}, + 'blc-noise': {'type': bool}, + 'blc-set-min': {'type': bool}, + 'dont-zero-nans': {'type': bool}, + 'dont-zero-orange': {'type': bool}, + 'max-pulses': {'type': list, 'msg': 'Range list of maximum pulse indices ' '(--max-pulses start end step). ' '3 max input elements. '}, - 'no-rel-gain': {'typ': bool}, - 'no-xray-gain': {'typ': bool}, - 'no-blc-noise': {'typ': bool}, - 'no-blc-set-min': {'typ': bool}, - 'no-dont-zero-nans': {'typ': bool}, - 'no-dont-zero-orange': {'typ': bool} + 'use-litframe-finder': {'type': str}, + 'litframe-device-id': {'type': str}, + 'energy-threshold': {'type': int}, + 'no-rel-gain': {'type': bool}, + 'no-xray-gain': {'type': bool}, + 'no-blc-noise': {'type': bool}, + 'no-blc-set-min': {'type': bool}, + 'no-dont-zero-nans': {'type': bool}, + 'no-dont-zero-orange': {'type': bool} }, { 'karabo-da': { - 'typ': list, + 'type': list, 'choices': [ 'AGIPD00', 'AGIPD01', 'AGIPD02', 'AGIPD03', 'AGIPD04', 'AGIPD05', 'AGIPD06', 'AGIPD07', diff --git a/webservice/update_config.py b/webservice/update_config.py index 5e5960e370cf1e1053c4c0c571c0650fd4ca9f70..f6a6f9d1f9bb7c7474724d955fd359f3f4fa2d5f 100755 --- a/webservice/update_config.py +++ b/webservice/update_config.py @@ -9,37 +9,40 @@ import zmq AGIPD_CONFIGURATIONS = { "correct": { - "force-hg-if-below": {'typ': int}, - "rel-gain": {'typ': bool}, - "xray-gain": {'typ': bool}, - "blc-noise": {'typ': bool}, - "blc-set-min": {'typ': bool}, - "dont-zero-nans": {'typ': bool}, - "dont-zero-orange": {'typ': bool}, - "max-pulses": {'typ': list, + "force-hg-if-below": {'type': int}, + "rel-gain": {'type': bool}, + "xray-gain": {'type': bool}, + "blc-noise": {'type': bool}, + "blc-set-min": {'type': bool}, + "dont-zero-nans": {'type': bool}, + "dont-zero-orange": {'type': bool}, + "max-pulses": {'type': list, 'msg': "Range list of maximum pulse indices " "(--max-pulses start end step). " "3 max input elements. "}, + 'use-litframe-finder': {'type': str}, + 'litframe-device-id': {'type': str}, + 'energy-threshold': {'type': int} }, "dark": { - "thresholds-offset-hard-hg": {'typ': list}, - "thresholds-offset-hard-mg": {'typ': list}, - "thresholds-offset-hard-lg": {'typ': list}, - "thresholds-offset-hard-hg-fixed": {'typ': list}, - "thresholds-offset-hard-mg-fixed": {'typ': list}, - "thresholds-offset-hard-lg-fixed": {'typ': list}, - "thresholds-offset-sigma": {'typ': list}, - "thresholds-noise-hard-hg": {'typ': list}, - "thresholds-noise-hard-mg": {'typ': list}, - "thresholds-noise-hard-lg": {'typ': list}, - "thresholds-noise-sigma": {'typ': list}, + "thresholds-offset-hard-hg": {'type': list}, + "thresholds-offset-hard-mg": {'type': list}, + "thresholds-offset-hard-lg": {'type': list}, + "thresholds-offset-hard-hg-fixed": {'type': list}, + "thresholds-offset-hard-mg-fixed": {'type': list}, + "thresholds-offset-hard-lg-fixed": {'type': list}, + "thresholds-offset-sigma": {'type': list}, + "thresholds-noise-hard-hg": {'type': list}, + "thresholds-noise-hard-mg": {'type': list}, + "thresholds-noise-hard-lg": {'type': list}, + "thresholds-noise-sigma": {'type': list}, } } DATA_MAPPING = { "karabo-da": { - 'typ': list, + 'type': list, 'choices': [f"AGIPD{i:02d}" for i in range(16)], 'msg': "Choices: [AGIPD00 ... AGIPD15]. " } @@ -108,19 +111,19 @@ def _add_available_configs_to_arg_parser(karabo_id: str, action: str): # Loop over action configurations in available_detectors dictionary. for key, val in AVAILABLE_DETECTORS[karabo_id][0][action].items(): available_conf[0][key] = val - if val['typ'] == bool: - available_conf[0][f'no-{key}'] = {'typ': bool} + if val['type'] == bool: + available_conf[0][f'no-{key}'] = {'type': bool} for conf in available_conf: for option, info in conf.items(): - typ = info['typ'] + type_ = info['type'] choices = info.get('choices') - if info['typ'] == list: + if info['type'] == list: arguments = { "action": 'append', "nargs": '+', } - typ = str + type_ = str # Avoid having a big line of choices in the help message. if choices: arguments.update({ @@ -135,10 +138,10 @@ def _add_available_configs_to_arg_parser(karabo_id: str, action: str): if 'msg' in info.keys(): help_msg += info['msg'] - help_msg += f"Type: {info['typ'].__name__} ".upper() + help_msg += f"Type: {info['type'].__name__} ".upper() parser.add_argument( f"--{option}", - type=typ, + type=type_, help=help_msg, **arguments, )