LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
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:490
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:509
def batchWallTime(cls, time, parsedCmd, numCores)
Definition: ingestDriver.py:9