Skip to content

Commit

Permalink
Use dayObs as bind parameter instead of day_obs in queries
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Mar 1, 2024
1 parent eb98f29 commit d446f01
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions python/lsst/summit/utils/butlerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ def getSeqNumsForDayObs(butler, day_obs, extraWhere=''):
order.
"""
day_obs = sanitizeDayObs(day_obs)
where = "exposure.day_obs=day_obs"
where = "exposure.day_obs=dayObs"
if extraWhere:
extraWhere = extraWhere.replace('"', '\'')
where += f" and {extraWhere}"
records = butler.registry.queryDimensionRecords("exposure",
where=where,
bind={'day_obs': day_obs},
bind={'dayObs': day_obs},
datasets='raw')
return sorted([r.seq_num for r in records])

Expand Down Expand Up @@ -507,10 +507,10 @@ def getExpRecordFromDataId(butler, dataId):
seqNum = getSeqNum(dataId)
if not (dayObs and seqNum):
raise RuntimeError(f'Failed to find either expId or day_obs and seq_num in dataId {dataId}')
where = "exposure.day_obs=day_obs AND exposure.seq_num=seq_num"
where = "exposure.day_obs=dayObs AND exposure.seq_num=seq_num"
expRecords = butler.registry.queryDimensionRecords("exposure",
where=where,
bind={'day_obs': dayObs, 'seq_num': seqNum},
bind={'dayObs': dayObs, 'seq_num': seqNum},
datasets='raw')

expRecords = set(expRecords)
Expand Down Expand Up @@ -748,13 +748,13 @@ def isOnSky(expRecord):
days = [d for d in days if d <= endDate]
days = sorted(set(days))

where = "exposure.day_obs=day_obs"
where = "exposure.day_obs=dayObs"
for day in days:
# queryDataIds would be better here, but it's then hard/impossible
# to do the filtering for which is on sky, so just take the dataIds
records = butler.registry.queryDimensionRecords("exposure",
where=where,
bind={'day_obs': day},
bind={'dayObs': day},
datasets='raw')
recordSets.append(sortRecordsByDayObsThenSeqNum(records))

Expand Down
4 changes: 2 additions & 2 deletions python/lsst/summit/utils/nightReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ def getExpRecordDictForDayObs(self, dayObs):
Runs in ~0.05s for 1000 records.
"""
expRecords = self.butler.registry.queryDimensionRecords("exposure",
where="exposure.day_obs=day_obs",
bind={'day_obs': dayObs},
where="exposure.day_obs=dayObs",
bind={'dayObs': dayObs},
datasets='raw')
expRecords = list(expRecords)
records = {e.seq_num: e.toDict() for e in expRecords} # not guaranteed to be in order
Expand Down
6 changes: 3 additions & 3 deletions tests/test_butlerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ def test_datasetExists(self):
return

def test_sortRecordsByDayObsThenSeqNum(self):
where = "exposure.day_obs=day_obs"
where = "exposure.day_obs=dayObs"
expRecords = self.butler.registry.queryDimensionRecords("exposure", where=where,
bind={'day_obs': RECENT_DAY})
bind={'dayObs': RECENT_DAY})
expRecords = list(expRecords)
self.assertGreaterEqual(len(expRecords), 1) # just ensure we're not doing a no-op test
random.shuffle(expRecords) # they are often already in order, so make sure they're not
Expand All @@ -256,7 +256,7 @@ def test_sortRecordsByDayObsThenSeqNum(self):
# Check that ambiguous sorts raise as expected
with self.assertRaises(ValueError):
expRecords = self.butler.registry.queryDimensionRecords("exposure", where=where,
bind={'day_obs': RECENT_DAY})
bind={'dayObs': RECENT_DAY})
expRecords = list(expRecords)
self.assertGreaterEqual(len(expRecords), 1) # just ensure we're not doing a no-op test
expRecords.append(expRecords[0]) # add a duplicate
Expand Down

0 comments on commit d446f01

Please sign in to comment.