All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
manageDataRunDefinitions.DimensionQueryMaker Class Reference

Public Member Functions

def __call__
 

Static Public Member Functions

def addParentheses
 
def simpleItem
 
def multiItem
 

Detailed Description

Callable object making a SAM query out of a `SampleInfo` object.

Definition at line 106 of file manageDataRunDefinitions.py.

Member Function Documentation

def manageDataRunDefinitions.DimensionQueryMaker.__call__ (   self,
  info 
)

Definition at line 110 of file manageDataRunDefinitions.py.

111  info: "SampleInfo object with all the information for the query",
112  minimum: "throws an exception if fewer than these elements are included" = 0,
113  ) -> "a SAM dimensions query string":
114 
115  dims = [
116  DimensionQueryMaker.simpleItem('run_number', info.run),
117  DimensionQueryMaker.multiItem(StageDimensions, info.stage, 'stage'),
118  DimensionQueryMaker.simpleItem('data_stream', info.stream),
119  DimensionQueryMaker.simpleItem('icarus_project.version', info.projectVersion),
120  ]
121  query = " and ".join(filter(None, dims))
122  if len(dims) < minimum:
123  raise RuntimeError(f"Query resulted in only {len(dims)} constraints: '{query}'")
return query
Framework includes.
S join(S const &sep, Coll const &s)
Returns a concatenation of strings in s separated by sep.
def manageDataRunDefinitions.DimensionQueryMaker.addParentheses (   s)
static

Definition at line 127 of file manageDataRunDefinitions.py.

128  def addParentheses(s): return "( " + s + " )" if s else ""
def manageDataRunDefinitions.DimensionQueryMaker.multiItem (   queries,
  values,
  typeName 
)
static

Definition at line 140 of file manageDataRunDefinitions.py.

141  def multiItem(queries, values, typeName):
142  values = SampleInfo.makeOptionList(values)
143  if not values or None in values: return ""
144  dims = []
145  for value in values:
146  try:
147  dims.append(queries[value])
148  except KeyError:
149  raise RuntimeError(f"{typeName} '{value}' not supported.")
150  # for
151  if len(dims) > 1: dims = list(map(DimensionQueryMaker.addParentheses, dims))
152  query = " or ".join(dims) if dims else ""
153  if len(dims) > 1: query = DimensionQueryMaker.addParentheses(query)
return query
S join(S const &sep, Coll const &s)
Returns a concatenation of strings in s separated by sep.
list
Definition: file_to_url.sh:28
def manageDataRunDefinitions.DimensionQueryMaker.simpleItem (   key,
  value,
  typeName = None 
)
static

Definition at line 130 of file manageDataRunDefinitions.py.

131  def simpleItem(key, value, typeName=None):
132  # if typeName is None: typeName = key
133  if SampleInfo.hasOptions(value):
134  return f"{key} in ( { ' '.join(map(str, value)) } )"
135  elif value is not None: return f"{key} {value}"
else: return ""

The documentation for this class was generated from the following file: