From 94498395ea4f953834d57e4cf6ef70a9d1fa1502 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Wed, 30 Mar 2022 15:17:10 +0200
Subject: [PATCH] correct variant spelling mistake and remove unneeded line

---
 src/cal_tools/agipdlib.py | 3 +--
 src/cal_tools/tools.py    | 7 +++----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/cal_tools/agipdlib.py b/src/cal_tools/agipdlib.py
index bd9e08f76..c967ae3c6 100644
--- a/src/cal_tools/agipdlib.py
+++ b/src/cal_tools/agipdlib.py
@@ -1207,13 +1207,12 @@ class AgipdCorrections:
         variant = dict()
         db_module = const_yaml[karabo_da]["physical-detector-unit"]
         for cname, mdata in const_yaml[karabo_da]["constants"].items():
-            cons_data[cname] = {}
             base_key = f"{db_module}/{cname}/0"
             when[cname] = mdata["creation-time"]
             if when[cname]:
                 with h5py.File(mdata["file-path"], "r") as cf:
                     cons_data[cname] = np.copy(cf[f"{base_key}/data"])
-                    # The vairant attribute is missing for old constants.
+                    # The variant attribute is missing for old constants.
                     if "variant" in cf[base_key].attrs.keys():
                         variant[cname] = cf[base_key].attrs["variant"]  # noqa
             else:
diff --git a/src/cal_tools/tools.py b/src/cal_tools/tools.py
index 81c0d7467..1ec6574d5 100644
--- a/src/cal_tools/tools.py
+++ b/src/cal_tools/tools.py
@@ -602,10 +602,9 @@ def get_from_db(karabo_id: str, karabo_da: str,
                     )
                 with h5py.File(Path(hdf5path, filename), "r") as f:
                     metadata.calibration_constant.data = f[f"{h5path}/data"][()]  # noqa
-                    # The vairant attribute is missing for old constants.
+                    # The variant attribute is missing for old constants.
                     if "variant" in f[h5path].attrs.keys():
-                        metadata.calibration_constant_version.variant = (
-                            f[h5path].attrs["variant"])
+                        metadata.calibration_constant_version.variant = f[h5path].attrs["variant"]  # noqa
 
             if verbosity > 0:
                 if constant.name not in already_printed or verbosity > 1:
@@ -628,7 +627,7 @@ def send_to_db(db_module: str, karabo_id: str, constant, condition,
                timeout: int = 30000,
                ntries: int = 7,
                doraise: bool = False,
-               variant: Optional[int] = None):
+               variant: int = 0):
     """Send new calibration constants and metadata requested to CalDB
 
     :param db_module: database module (PDU/Physical Detector Unit)
-- 
GitLab