LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
LSSTDataManagementBasePackage
Functions | Variables
lsst.datarel.ingest Namespace Reference

Functions

def _line_to_args
 
def makeArgumentParser
 
def makeRules
 

Variables

list __all__
 

Function Documentation

def lsst.datarel.ingest._line_to_args (   self,
  line 
)
private

Definition at line 33 of file ingest.py.

33 
34 def _line_to_args(self, line):
35  for arg in shlex.split(line, comments=True, posix=True):
36  if not arg.strip():
37  continue
38  yield arg
39 
def lsst.datarel.ingest.makeArgumentParser (   description,
  inRootsRequired = True,
  addRegistryOption = True 
)

Definition at line 40 of file ingest.py.

40 
41 def makeArgumentParser(description, inRootsRequired=True, addRegistryOption=True):
42  parser = argparse.ArgumentParser(
43  description=description,
44  fromfile_prefix_chars="@",
45  formatter_class=argparse.RawDescriptionHelpFormatter,
46  epilog="Data IDs are expected to be of the form:\n"
47  " --id k1=v11[^v12[...]] [k2=v21[^v22[...]]\n"
48  "\n"
49  "Examples:\n"
50  " 1. --id visit=12345 raft=1,1\n"
51  " 2. --id skyTile=12345\n"
52  " 3. --id visit=12 raft=1,2^2,2 sensor=1,1^1,3\n"
53  "\n"
54  "The first example identifies all sensors in raft 1,1 of visit "
55  "12345. The second identifies all sources/objects in sky-tile "
56  "12345. The cross product is computed for keys with multiple "
57  "values, so the third example is equivalent to:\n"
58  " --id visit=12 raft=1,2 sensor=1,1\n"
59  " --id visit=12 raft=1,2 sensor=1,3\n"
60  " --id visit=12 raft=2,2 sensor=1,1\n"
61  " --id visit=12 raft=2,2 sensor=1,3\n"
62  "\n"
63  "Redundant specification of a data ID will *not* result in "
64  "loads of duplicate data - data IDs are de-duped before ingest "
65  "starts. Note also that the keys allowed in data IDs are "
66  "specific to the type of data the ingestion script deals with. "
67  "For example, one cannot load sensor metadata by sky tile ID, nor "
68  "sources by sensor (CCD) ID.\n"
69  "\n"
70  "Any omitted keys are assumed to take all legal values. So, "
71  "`--id raft=1,2` identifies all sensors of raft 1,2 for all "
72  "available visits.\n"
73  "\n"
74  "Finally, calling an ingestion script multiple times is safe. "
75  "Attempting to load the same data item twice will result "
76  "in an error or (if --strict is specified) or cause previously "
77  "loaded data item to be skipped. Database activity is strictly "
78  "append only.")
79  parser.convert_arg_line_to_args = _line_to_args
80  addDbOptions(parser)
81  parser.add_argument(
82  "-d", "--database", dest="database",
83  help="MySQL database to load CSV files into.")
84  parser.add_argument(
85  "-s", "--strict", dest="strict", action="store_true",
86  help="Error out if previously ingested, incomplete, or otherwise "
87  "suspicious data items are encountered (by default, these are "
88  "skipped). Note that if --database is not supplied, detecting "
89  "previously ingested data is not possible.")
90  parser.add_argument(
91  "-i", "--id", dest="id", nargs="+", default=None, action="append",
92  help="Data ID specifying what to ingest. May appear multiple times.")
93  if addRegistryOption:
94  parser.add_argument(
95  "-R", "--registry", dest="registry", help="Input registry path; "
96  "used for all input roots. If omitted, a file named registry.sqlite3 "
97  "must exist in each input root.")
98  parser.add_argument(
99  "outroot", help="Output directory for CSV files")
100  parser.add_argument(
101  "inroot", nargs="+" if inRootsRequired else "*",
102  help="One or more input root directories")
103  return parser
104 
def makeArgumentParser
Definition: ingest.py:40
def lsst.datarel.ingest.makeRules (   dataIdSpecs,
  camera,
  validKeys 
)
Return a list of data ID rules from command line --id specifications.
Ensures only the given keys are referenced by the data id specs.

Definition at line 105 of file ingest.py.

106 def makeRules(dataIdSpecs, camera, validKeys):
107  """Return a list of data ID rules from command line --id specifications.
108  Ensures only the given keys are referenced by the data id specs."""
109  if not dataIdSpecs:
110  return None
111  rules = []
112  for id in dataIdSpecs:
113  r = parseDataIdRules(id, camera)
114  for k in r:
115  if k not in validKeys:
116  raise RuntimeError(k + " is not a legal data ID key for this ingest script")
117  rules.append(r)
118  return rules

Variable Documentation

list lsst.datarel.ingest.__all__
Initial value:
1 = ["makeArgumentParser",
2  "makeRules",
3  ]

Definition at line 28 of file ingest.py.