Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-41312: Fix blockInfo parsing for minimal data #65

Merged
merged 4 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you also need this check in augmentDataSlow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually tested and didn't, but it was because I was getting zero rows of data, and thus the iterrows() there was meaning that line never got hit, so you're right, if I only got few but non-zero lines that would need be necessary! Thanks - added 👍

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