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-23342: Fix ingestDriver #88

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 29 additions & 2 deletions python/lsst/pipe/drivers/ingestDriver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from lsst.ctrl.pool.pool import Pool, startPool, abortOnError
from lsst.ctrl.pool.parallel import BatchCmdLineTask
from lsst.pipe.tasks.ingest import IngestTask
from lsst.pipe.base import Struct
from lsst.pipe.tasks.ingest import IngestTask, IngestError


class PoolIngestTask(BatchCmdLineTask, IngestTask):
Expand Down Expand Up @@ -30,6 +31,31 @@ def parseAndRun(cls, *args, **kwargs):
task.run(args)
pool.exit()

def runFileWrapper(self, struct, args):
"""Run ingest on one file

This is a wrapper method for calling ``runFile``.

Parameters
----------
struct : `lsst.pipe.base.Struct`
Structure containing ``filename`` (`str`) and ``position`` (`int`).
args : `argparse.Namespace`
Parsed command-line arguments.

Returns
-------
hduInfoList : `list` of `dict`
Parsed information from FITS HDUs, or ``None``.
"""
filename = struct.filename
position = struct.position
try:
return self.runFile(filename, None, args, position)
except IngestError as exc:
self.log.warn(f"Unable to ingest {filename}: {exc}")
return None

@abortOnError
def run(self, args):
"""Run ingest
Expand All @@ -40,7 +66,8 @@ def run(self, args):
# Parallel
pool = Pool(None)
filenameList = self.expandFiles(args.files)
infoList = pool.map(self.runFile, filenameList, None, args)
dataList = [Struct(filename=filename, position=ii) for ii, filename in enumerate(filenameList)]
infoList = pool.map(self.runFileWrapper, dataList, args)

# Serial
root = args.input
Expand Down