diff --git a/python/lsst/summit/utils/blockUtils.py b/python/lsst/summit/utils/blockUtils.py index a7d75616..207eb4f8 100644 --- a/python/lsst/summit/utils/blockUtils.py +++ b/python/lsst/summit/utils/blockUtils.py @@ -212,6 +212,11 @@ def augmentDataSlow(self): data['blockDayObs'] = pd.Series() data['blockSeqNum'] = pd.Series() + if 'lastCheckpoint' not in self.data.columns: + nRows = len(self.data) + self.log.warning(f"Found {nRows} rows of data and no 'lastCheckpoint' column was in the data," + " so block data cannot be parsed.") + for index, row in data.iterrows(): rowStr = row['lastCheckpoint'] @@ -236,6 +241,17 @@ def augmentData(self): but is also much harder to maintain/debug, as the vectorized regexes are hard to work with, and to know which row is causing problems. """ + if 'lastCheckpoint' not in self.data.columns: + nRows = len(self.data) + self.log.warning(f"Found {nRows} rows of data and no 'lastCheckpoint' column was in the data," + " so block data cannot be parsed.") + # add the columns that would have been added for consistency + self.data['blockNum'] = pd.Series() + self.data['blockId'] = pd.Series() + self.data['blockDayObs'] = pd.Series() + self.data['blockSeqNum'] = pd.Series() + return + data = self.data blockPattern = r"BLOCK-(\d+)" blockIdPattern = r"(BL\d+(?:_\w+)+)" diff --git a/python/lsst/summit/utils/tmaUtils.py b/python/lsst/summit/utils/tmaUtils.py index f05ef531..742d2e08 100644 --- a/python/lsst/summit/utils/tmaUtils.py +++ b/python/lsst/summit/utils/tmaUtils.py @@ -1318,7 +1318,15 @@ def addBlockDataToEvents(self, dayObs, events): `list` of `lsst.summit.utils.tmaUtils.TMAEvent` One or more events to get the block data for. """ - blockParser = BlockParser(dayObs, client=self.client) + try: + blockParser = BlockParser(dayObs, client=self.client) + except Exception as e: + # adding the block data should never cause a failure so if we can't + # get the block data, log a warning and return. It is, however, + # never expected, so use log.exception to get the full traceback + # and scare users so it gets reported + self.log.exception(f'Failed to parse block data for {dayObs=}, {e}') + return blocks = blockParser.getBlockNums() blockDict = {} for block in blocks: