LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
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:469
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:488
def batchWallTime(cls, time, parsedCmd, numCores)
Definition: ingestDriver.py:9