Skip to content
Snippets Groups Projects

karabo_da to list, jungfrau parallel dark, update conf

Merged Karim Ahmed requested to merge fix/2.8.5-dark_nbs_and_update_conf into master
All threads resolved!
1 file
+ 22
31
Compare changes
  • Side-by-side
  • Inline
+ 22
31
@@ -5,37 +5,29 @@ import sys
import yaml
import zmq
# Defining available options
agipd_options = {
"force-hg-if-below": float,
"rel_gain": bool,
"xray_gain": bool,
"blc-noise": bool,
"blc-stripes": bool,
"blc-set-min": bool,
"dont-zero-nans": bool,
"dont-zero-orange": bool,
"max-pulses": list,
"calfile": str
}
available_options = {
"SPB_DET_AGIPD1M-1": agipd_options,
"MID_DET_AGIPD1M-1": agipd_options}
"AGIPD": {"force-hg-if-below": float,
"rel_gain": bool,
"xray_gain": bool,
"blc-noise": bool,
"blc-stripes": bool,
"blc-set-min": bool,
"dont-zero-nans": bool,
"dont-zero-orange": bool,
"max-pulses": list,
"calfile": str},
}
parser = argparse.ArgumentParser(
description='Request update of configuration')
required_args = parser.add_argument_group('required arguments')
required_args.add_argument('--karabo-id', type=str,
choices=['SPB_DET_AGIPD1M-1',
'MID_DET_AGIPD1M-1'])
required_args.add_argument('--detector', type=str, choices=['AGIPD'])
required_args.add_argument('--task', type=str, choices=['correct', 'dark'])
required_args.add_argument('--proposal', type=str,
help='The proposal number, without leading p, but with leading zeros') # noqa
required_args.add_argument('--instrument', type=str,
choices=["SPB", "MID", "FXE", "SCS", "SQS", "HED",
"DETLAB, CALLAB"], help='The instrument') # noqa
"DETLAB"], help='The instrument') # noqa
required_args.add_argument('--cycle', type=str, help='The facility cycle')
parser.add_argument('--apply', action='store_true')
# remove help calls as they will cause the argument parser to exit
@@ -57,10 +49,10 @@ for det, val in available_options.items():
known, remaining = parser.parse_known_args()
args = vars(known)
karabo_id = args["karabo_id"]
detector = args["detector"]
if karabo_id is not None:
for option, typ in available_options[karabo_id].items():
if detector is not None:
for option, typ in available_options[detector].items():
if typ == list:
nargs = '+'
else:
@@ -81,10 +73,10 @@ if task is None or instrument is None or proposal is None or cycle is None:
print("Need to define all fields")
exit()
new_conf = {task: {instrument: {karabo_id: {}}}}
new_conf = {task: {instrument: {detector: {}}}}
for key, value in args.items():
key = key.replace("_", "-")
if key in available_options[karabo_id] and value is not None:
if key in available_options[detector] and value is not None:
if isinstance(value, list):
for v in value:
@@ -92,7 +84,7 @@ for key, value in args.items():
if 'no-' in key and isinstance(value, bool):
if key not in bool_keys:
new_conf[task][instrument][karabo_id][key.replace('no-','')] = False #noqa
new_conf[task][instrument][detector][key.replace('no-','')] = False #noqa
# avoid saving the "no-"key into the updated config
continue
# Assure adding an empty string for new empty
@@ -100,7 +92,7 @@ for key, value in args.items():
if isinstance(key, str) and (value == '' or value == ' '):
value = '""'
new_conf[task][instrument][karabo_id][key] = value
new_conf[task][instrument][detector][key] = value
pyaml = yaml.dump(new_conf, default_flow_style=False)
@@ -116,9 +108,8 @@ print("-" * 80)
con = zmq.Context()
socket = con.socket(zmq.REQ)
con = socket.connect("tcp://max-exfl016:5555")
msg = "','".join(["update_conf", "SASEX", args["karabo_id"],
args["instrument"], args["cycle"], args["proposal"],
json.dumps(new_conf), str(args["apply"])])
msg = "','".join(["update_conf", "SASEX", args["instrument"], args["cycle"],
args["proposal"], json.dumps(new_conf), str(args["apply"])])
socket.send("['{}']".format(msg).encode())
resp = socket.recv_multipart()[0]
print("Configuration now in place is:")
Loading