LSSTApplications  11.0-24-g0a022a1,14.0+77,15.0,15.0+1
LSSTDataManagementBasePackage
Functions | Variables
lsst.datarel.ingest Namespace Reference

Functions

def _line_to_args (self, line)
 
def makeArgumentParser (description, inRootsRequired=True, addRegistryOption=True)
 
def makeRules (dataIdSpecs, camera, validKeys)
 

Variables

list __all__
 

Function Documentation

◆ _line_to_args()

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

Definition at line 33 of file ingest.py.

33 def _line_to_args(self, line):
34  for arg in shlex.split(line, comments=True, posix=True):
35  if not arg.strip():
36  continue
37  yield arg
38 
39 
def _line_to_args(self, line)
Definition: ingest.py:33

◆ makeArgumentParser()

def lsst.datarel.ingest.makeArgumentParser (   description,
  inRootsRequired = True,
  addRegistryOption = True 
)

Definition at line 40 of file ingest.py.

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

◆ makeRules()

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.

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

Variable Documentation

◆ __all__

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

Definition at line 28 of file ingest.py.