LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
ingestDriver.py
Go to the documentation of this file.
1 from lsst.ctrl.pool.pool import Pool, startPool, abortOnError
2 from lsst.ctrl.pool.parallel import BatchCmdLineTask
3 from lsst.pipe.tasks.ingest import IngestTask
4 
5 
7  """Parallel version of IngestTask"""
8  @classmethod
9  def batchWallTime(cls, time, parsedCmd, numCores):
10  return float(time)*len(parsedCmd.files)/numCores
11 
12  @classmethod
13  def _makeArgumentParser(cls, *args, **kwargs):
14  """Build an ArgumentParser
15 
16  Removes the batch-specific parts.
17  """
18  kwargs.pop("doBatch", False)
19  kwargs.pop("add_help", False)
20  return cls.ArgumentParser(*args, name="ingest", **kwargs)
21 
22  @classmethod
23  def parseAndRun(cls, *args, **kwargs):
24  """Run with a MPI process pool"""
25  pool = startPool()
26  config = cls.ConfigClass()
27  parser = cls.ArgumentParser(name=cls._DefaultName)
28  args = parser.parse_args(config)
29  task = cls(config=args.config)
30  task.run(args)
31  pool.exit()
32 
33  @abortOnError
34  def run(self, args):
35  """Run ingest
36 
37  We read and ingest the files in parallel, and then
38  stuff the registry database in serial.
39  """
40  # Parallel
41  pool = Pool(None)
42  filenameList = self.expandFiles(args.files)
43  infoList = pool.map(self.runFile, filenameList, None, args)
44 
45  # Serial
46  root = args.input
47  context = self.register.openRegistry(root, create=args.create, dryrun=args.dryrun)
48  with context as registry:
49  for hduInfoList in infoList:
50  if hduInfoList is None:
51  continue
52  for info in hduInfoList:
53  self.register.addRow(registry, info, dryrun=args.dryrun, create=args.create)
54 
55  def writeConfig(self, *args, **kwargs):
56  pass
57 
58  def writeMetadata(self, *args, **kwargs):
59  pass
def expandFiles(self, fileNameList)
Expand a set of filenames and globs, returning a list of filenames.
Definition: ingest.py:546
def startPool(comm=None, root=0, killSlaves=True)
Start a process pool.
Definition: pool.py:1216
def runFile(self, infile, registry, args)
Examine and ingest a single file.
Definition: ingest.py:565
def batchWallTime(cls, time, parsedCmd, numCores)
Definition: ingestDriver.py:9