From 27b6e4b92a31096ce4dfb29510a5c1b8609f0dea Mon Sep 17 00:00:00 2001 From: Kian-Tat Lim Date: Fri, 6 Sep 2024 16:45:54 -0700 Subject: [PATCH] Protect against missing GROUPID header. --- src/ingest.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ingest.py b/src/ingest.py index ccb8909..feb5660 100644 --- a/src/ingest.py +++ b/src/ingest.py @@ -174,14 +174,15 @@ def record_groups(resources: list[ResourcePath]) -> None: instrument = "LSSTCam" case "latiss": instrument = "LATISS" - groupid = header["GROUPID"] - snap_number = int(header["CURINDEX"]) - 1 - detector = header["RAFTBAY"] + "_" + header["CCDSLOT"] - key = f"GROUP:{instrument}:{groupid}:{snap_number}:{detector}" - pipe.set(key, str(res)) - pipe.expire(key, group_lifetime) + if "GROUPID" in header: + groupid = header["GROUPID"] + snap_number = int(header["CURINDEX"]) - 1 + detector = header["RAFTBAY"] + "_" + header["CCDSLOT"] + key = f"GROUP:{instrument}:{groupid}:{snap_number}:{detector}" + pipe.set(key, str(res)) + pipe.expire(key, group_lifetime) except Exception: - logger.exception("Error reading group for %s", res) + logger.exception("Error reading snap/detector for %s", res) pipe.execute()