Skip to content

Commit

Permalink
Rename CmdlineTask's entry method runDataRef
Browse files Browse the repository at this point in the history
Prepare Tasks for Gen3 PipelineTask conversion by:
* Renaming CmdlineTask's entry method to `runDataRef`.  The default
  CmdlineTask.TaskRunner now calls a Task's `runDataRef` method on the
  parsed command line inputs.
  `runDataRef` method can take any Gen2 Butler data products.
* Renaming CmdlineTasks previous core methods (e.g. assemble,
  characterize) to `run` when they exist.
  • Loading branch information
czwa committed Aug 3, 2018
1 parent ed8029f commit 7d77e3b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions python/lsst/meas/mosaic/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _makeArgumentParser(cls):
ContainerClass=PerTractCcdDataIdContainer)
return parser

def run(self, dataRef):
def runDataRef(self, dataRef):
catalog = dataRef.get("src", immediate=True)
calexp_md = dataRef.get('calexp_md', immediate=True)
# Check if we are looking at HSC stack outputs
Expand Down Expand Up @@ -59,7 +59,7 @@ def _makeArgumentParser(cls):
ContainerClass=PerTractCcdDataIdContainer)
return parser

def run(self, dataRef):
def runDataRef(self, dataRef):
results = applyMosaicResultsExposure(dataRef)
dataRef.put(results.exposure, "calibrated_exp")

Expand Down
6 changes: 3 additions & 3 deletions python/lsst/meas/mosaic/checkMosaicTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def writeCatalog(self, allSource, wcsDic, calibDic, ffpDic):
outHdu.writeto("catalog_check.fits", clobber=True)


def check(self, dataRefList, ct=None, debug=False, verbose=False):
def run(self, dataRefList, ct=None, debug=False, verbose=False):
ccdSet = self.readCcd(dataRefList)
self.removeNonExistCcd(dataRefList, ccdSet)

Expand Down Expand Up @@ -548,7 +548,7 @@ def check(self, dataRefList, ct=None, debug=False, verbose=False):
self.plotPosAsMag(m0_s, dx_s, dy_s)
self.writeCatalog(allSource, wcsDic, calibDic, ffpDic)

def run(self, camera, butler, tract, dataRefList, debug):
def runDataRef(self, dataRefList, camera, butler, tract, debug):

colorterms = ColortermLibrary()
name = os.path.join(os.environ["OBS_SUBARU_DIR"], "config", camera, "colorterms.py")
Expand All @@ -566,7 +566,7 @@ def run(self, camera, butler, tract, dataRefList, debug):

ct = colorterms.getColorterm(butler.mapper.filters[filters[0]], self.config.photoCatName)

return self.check(dataRefList, ct, debug)
return self.run(dataRefList, ct, debug)

if __name__ == '__main__':

Expand Down
25 changes: 13 additions & 12 deletions python/lsst/meas/mosaic/mosaicTask.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
class MosaicRunner(pipeBase.TaskRunner):
"""Subclass of TaskRunner for MosaicTask
MosaicTask.run() takes a number of arguments, one of which is a list of dataRefs
extracted from the command line (whereas most CmdLineTasks' run methods take
MosaicTask.runDataRef() takes a number of arguments, one of which is a list of dataRefs
extracted from the command line (whereas most CmdLineTasks' runDataRef methods take
single dataRef, are are called repeatedly). This class transforms the processed
arguments generated by the ArgumentParser into the arguments expected by
MosaicTask.run().
MosaicTask.runDataRef().
See pipeBase.TaskRunner for more information, but note that the multiprocessing
code path does not apply, because MosaicTask.canMultiprocess == False.
Expand All @@ -63,10 +63,10 @@ def getTargetList(parsedCmd, **kwargs):
for ref in parsedCmd.id.refList:
refListDict.setdefault(ref.dataId["tract"], []).append(ref)
# we call run() once with each tract
return [(parsedCmd.camera,
return [(refListDict[tract],
parsedCmd.camera,
parsedCmd.butler,
tract,
refListDict[tract],
parsedCmd.debug,
parsedCmd.diagDir,
parsedCmd.diagnostics,
Expand All @@ -77,7 +77,7 @@ def getTargetList(parsedCmd, **kwargs):

def __call__(self, args):
task = self.TaskClass(config=self.config, log=self.log)
result = task.run(*args)
result = task.runDataRef(*args)
return pipeBase.Struct(exitStatus=0)

class MosaicConfig(pexConfig.Config):
Expand Down Expand Up @@ -849,8 +849,8 @@ def checkOverlapWithTract(self, tractInfo, dataRefList, verbose=False):

return dataRefListOverlapWithTract, dataRefListToUse

def mosaic(self, dataRefList, tractInfo, ct=None, debug=False, diagDir=".",
diagnostics=False, snapshots=False, numCoresForReadSource=1, readTimeout=9999, verbose=False):
def run(self, dataRefList, tractInfo, ct=None, debug=False, diagDir=".",
diagnostics=False, snapshots=False, numCoresForReadSource=1, readTimeout=9999, verbose=False):

self.log.info(str(self.config))

Expand Down Expand Up @@ -1025,8 +1025,9 @@ def mosaic(self, dataRefList, tractInfo, ct=None, debug=False, diagDir=".",
return list(wcsDic.keys())


def run(self, camera, butler, tract, dataRefList, debug, diagDir=".",
diagnostics=False, snapshots=False, numCoresForReadSource=1, readTimeout=9999, verbose=False):
def runDataRef(self, dataRefList, camera, butler, tract, debug, diagDir=".",
diagnostics=False, snapshots=False, numCoresForReadSource=1,
readTimeout=9999, verbose=False):
self.log.info("Running self-calibration for tract %d" % tract)
skyMap = butler.get("deepCoadd_skyMap", immediate=True)
tractInfo = skyMap[tract]
Expand All @@ -1050,5 +1051,5 @@ def run(self, camera, butler, tract, dataRefList, debug, diagDir=".",
ct = None
self.log.info("Not applying color term")

return self.mosaic(dataRefList, tractInfo, ct, debug, diagDir, diagnostics, snapshots,
numCoresForReadSource, readTimeout, verbose)
return self.run(dataRefList, tractInfo, ct, debug, diagDir, diagnostics, snapshots,
numCoresForReadSource, readTimeout, verbose)

0 comments on commit 7d77e3b

Please sign in to comment.