LSSTApplications  17.0+124,17.0+14,17.0+73,18.0.0+37,18.0.0+80,18.0.0-4-g68ffd23+4,18.1.0-1-g0001055+12,18.1.0-1-g03d53ef+5,18.1.0-1-g1349e88+55,18.1.0-1-g2505f39+44,18.1.0-1-g5315e5e+4,18.1.0-1-g5e4b7ea+14,18.1.0-1-g7e8fceb+4,18.1.0-1-g85f8cd4+48,18.1.0-1-g8ff0b9f+4,18.1.0-1-ga2c679d+1,18.1.0-1-gd55f500+35,18.1.0-10-gb58edde+2,18.1.0-11-g0997b02+4,18.1.0-13-gfe4edf0b+12,18.1.0-14-g259bd21+21,18.1.0-19-gdb69f3f+2,18.1.0-2-g5f9922c+24,18.1.0-2-gd3b74e5+11,18.1.0-2-gfbf3545+32,18.1.0-26-g728bddb4+5,18.1.0-27-g6ff7ca9+2,18.1.0-3-g52aa583+25,18.1.0-3-g8ea57af+9,18.1.0-3-gb69f684+42,18.1.0-3-gfcaddf3+6,18.1.0-32-gd8786685a,18.1.0-4-gf3f9b77+6,18.1.0-5-g1dd662b+2,18.1.0-5-g6dbcb01+41,18.1.0-6-gae77429+3,18.1.0-7-g9d75d83+9,18.1.0-7-gae09a6d+30,18.1.0-9-gc381ef5+4,w.2019.45
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  self.register.addVisits(registry, dryrun=args.dryrun)
55 
56  def writeConfig(self, *args, **kwargs):
57  pass
58 
59  def writeMetadata(self, *args, **kwargs):
60  pass
def expandFiles(self, fileNameList)
Expand a set of filenames and globs, returning a list of filenames.
Definition: ingest.py:499
def startPool(comm=None, root=0, killSlaves=True)
Start a process pool.
Definition: pool.py:1217
def runFile(self, infile, registry, args)
Examine and ingest a single file.
Definition: ingest.py:518
def batchWallTime(cls, time, parsedCmd, numCores)
Definition: ingestDriver.py:9