Skip to content

Commit

Permalink
Merge pull request #65 from lsst-sitcom/tickets/DM-41312
Browse files Browse the repository at this point in the history
DM-41312: Fix blockInfo parsing for minimal data
  • Loading branch information
mfisherlevine authored Oct 26, 2023
2 parents dddff91 + 88c2392 commit 5211ad5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
16 changes: 16 additions & 0 deletions python/lsst/summit/utils/blockUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand All @@ -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+)+)"
Expand Down
10 changes: 9 additions & 1 deletion python/lsst/summit/utils/tmaUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5211ad5

Please sign in to comment.