diff --git a/src/cal_tools/constants.py b/src/cal_tools/constants.py index bef79dc4e7e307f5f2e0fff66c51c00b3613c815..a5052a1e261c23b83aae5f2c86ffd5fb36caf759 100644 --- a/src/cal_tools/constants.py +++ b/src/cal_tools/constants.py @@ -137,7 +137,7 @@ def inject_ccv(const_src, ccv_root, report_to): unique_name = detector_type[:detector_type.index('-Type')] + ' Def' cond_hash = md5(pdu_name.encode()) cond_hash.update(pdu_uuid.to_bytes( - length=8, byteorder='little', signed=False))3 + length=8, byteorder='little', signed=False)) for param_dict in cond_params: cond_hash.update(str(param_dict['parameter_name']).encode()) @@ -194,9 +194,12 @@ def inject_ccv(const_src, ccv_root, report_to): copyfile(const_src, const_dest) -def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, pdu, const_input, begin_at): +def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, + pdu, const_input, begin_at): """Inject new CCV into CalCat. + LEGACY VERSION - DO NOT USE + (from before most details were saved in CCV file itself) metadata_folder calibration -> in file, but pass anyway as there could be multiple @@ -209,13 +212,15 @@ def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, pdu, metadata_folder, # Same as notebook parameter [run_high, run_mid, run_low], 'Offset', - current_pdu, # Element of calibration_client.from get_all_phy_det_units_from_detector + current_pdu, # Element of calibration_client.from + # get_all_phy_det_units_from_detector out_folder / 'my-constant-file.h5', get_dir_creation_date(in_folder, run_high) ) Args: - in_folder (str or Path): Root for input data, i.e. *not* containing r{run:04d} folder + in_folder (str or Path): Root for input data, i.e. *not* + containing r{run:04d} folder metadata_folder (str or Path): Metadata location runs (Iterable of str or int): Run number(s) used for characterization. calibration (str): Calibration name, e.g. 'Offset', must exist in CalCat. @@ -246,7 +251,8 @@ def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, pdu, # Generate condition name. unique_name = detector_type[:detector_type.index('-Type')] + ' Def' cond_hash = hashlib.md5(pdu_name.encode()) - cond_hash.update(pdu['uuid'].to_bytes(length=8, byteorder='little', signed=False)) + cond_hash.update(pdu['uuid'].to_bytes( + length=8, byteorder='little', signed=False)) for key, value in cond_dict.items(): cond_hash.update(str(key).encode()) @@ -305,7 +311,8 @@ def inject_ccv_legacy(in_folder, metadata_folder, runs, calibration, cond, pdu, } } - resp = CalibrationClient.inject_new_calibration_constant_version(calibration_client(), inject_h) + resp = CalibrationClient.inject_new_calibration_constant_version( + calibration_client(), inject_h) if not resp['success']: raise RuntimeError(resp)