Skip to content

Commit

Permalink
Only delete images if we are finished with them
Browse files Browse the repository at this point in the history
Work around segfault when doing afwImage.MaskedImageF(None)
  • Loading branch information
mfisherlevine committed Oct 27, 2023
1 parent 0c025fa commit 8a82f2b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
23 changes: 16 additions & 7 deletions python/lsst/rubintv/production/slac/botTesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,10 @@ def runCcobAnalysis(self, expRecord, timeout):
deleteIfComplete=False,
deleteRegardless=False,
)
if image is None:
self.log.warning(f'No mosaic found for {expRecord.dataId}')
return None

spotInfo = analyzeCcobSpotImage(image, binning=binning)

dayObs = expRecord.day_obs
Expand Down Expand Up @@ -842,18 +846,23 @@ def callback(self, expRecord, doPlotMosaic=False, doPlotNoises=False, doCcobAnal
# TODO: Need some kind of wait mechanism for each of these
if doPlotNoises:
noiseMapFile = self.plotNoises(expRecord, timeout=timeout)
channel = f'{instPrefix}_noise_map'
self.uploader.uploadPerSeqNumPlot(channel, dayObs, seqNum, noiseMapFile)
if noiseMapFile:
channel = f'{instPrefix}_noise_map'
self.uploader.uploadPerSeqNumPlot(channel, dayObs, seqNum, noiseMapFile)

if doPlotMosaic:
focalPlaneFile = self.plotFocalPlane(expRecord, timeout=timeout)
channel = f'{instPrefix}_focal_plane_mosaic'
self.uploader.uploadPerSeqNumPlot(channel, dayObs, seqNum, focalPlaneFile)
focalPlaneFile = self.plotFocalPlane(expRecord,
timeout=timeout,
doNotDelete=doCcobAnalysis)
if focalPlaneFile:
channel = f'{instPrefix}_focal_plane_mosaic'
self.uploader.uploadPerSeqNumPlot(channel, dayObs, seqNum, focalPlaneFile)

if doCcobAnalysis:
ccobAnalsisPlot = self.runCcobAnalysis(expRecord, timeout=timeout)
channel = f'{instPrefix}_ccob_analysis'
self.uploader.uploadPerSeqNumPlot(channel, dayObs, seqNum, ccobAnalsisPlot, isLiveFile=True)
if ccobAnalsisPlot:
channel = f'{instPrefix}_ccob_analysis'
self.uploader.uploadPerSeqNumPlot(channel, dayObs, seqNum, ccobAnalsisPlot, isLiveFile=True)

def run(self):
"""Run continuously, calling the callback method with the latest
Expand Down
18 changes: 18 additions & 0 deletions python/lsst/rubintv/production/slac/mosaicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ def makeMosaic(deferredDatasetRefs,
nExpected,
deleteIfComplete,
deleteRegardless,
doNotDelete,
logger=None):
"""Make a binned mosaic image from a list of deferredDatasetRefs.
Expand All @@ -297,6 +298,8 @@ def makeMosaic(deferredDatasetRefs,
is the number which was found.
deleteRegardless : `bool`, optional
If True, delete the binned images regardless of how many are found.
doNotDelete : `bool`, optional
If True, do not delete the binned images after reading them.
logger : `logging.Logger`, optional
The logger, created if not provided.
deleteAfterReading : `bool`
Expand All @@ -321,6 +324,11 @@ def makeMosaic(deferredDatasetRefs,
if logger is None:
logger = logging.getLogger(__name__)

if doNotDelete:
if deleteRegardless:
raise ValueError("doNotDelete and deleteRegardless are mutually exclusive")
deleteIfComplete = False

instrument = camera.getName()

detectorNameList = []
Expand Down Expand Up @@ -437,6 +445,7 @@ def plotFocalPlaneMosaic(butler,
timeout,
deleteIfComplete=True,
deleteRegardless=False,
doNotDelete=False,
logger=None):
"""Save a full focal plane binned mosaic image for a given expId.
Expand Down Expand Up @@ -468,6 +477,10 @@ def plotFocalPlaneMosaic(butler,
is the number which was found.
deleteRegardless : `bool`, optional
If True, delete the binned images regardless of how many are found.
`doNotDelete` trumps `deleteIfComplete`, but raises a ValueError if
used with `deleteRegardless`.
doNotDelete : `bool`, optional
If True, do not delete the binned images after reading them.
logger : `logging.Logger`, optional
The logger, created if not provided.
Expand All @@ -488,6 +501,7 @@ def plotFocalPlaneMosaic(butler,
timeout=timeout,
deleteIfComplete=deleteIfComplete,
deleteRegardless=deleteRegardless,
doNotDelete=doNotDelete,
logger=logger)

if mosaic is None:
Expand All @@ -507,6 +521,7 @@ def getMosaicImage(butler,
timeout,
deleteIfComplete=True,
deleteRegardless=False,
doNotDelete=False,
logger=None):
"""Save a full focal plane binned mosaic image for a given expId.
Expand Down Expand Up @@ -534,6 +549,8 @@ def getMosaicImage(butler,
is the number which was found.
deleteRegardless : `bool`, optional
If True, delete the binned images regardless of how many are found.
doNotDelete : `bool`, optional
If True, do not delete the binned images after reading them.
logger : `logging.Logger`, optional
The logger, created if not provided.
Expand Down Expand Up @@ -567,6 +584,7 @@ def getMosaicImage(butler,
nExpected=nExpected,
deleteIfComplete=deleteIfComplete,
deleteRegardless=deleteRegardless,
doNotDelete=doNotDelete,
logger=logger
).output_mosaic
if mosaic is None:
Expand Down

0 comments on commit 8a82f2b

Please sign in to comment.