LSST Applications  22.0.1,22.0.1+01bcf6a671,22.0.1+046ee49490,22.0.1+05c7de27da,22.0.1+0c6914dbf6,22.0.1+1220d50b50,22.0.1+12fd109e95,22.0.1+1a1dd69893,22.0.1+1c910dc348,22.0.1+1ef34551f5,22.0.1+30170c3d08,22.0.1+39153823fd,22.0.1+611137eacc,22.0.1+771eb1e3e8,22.0.1+94e66cc9ed,22.0.1+9a075d06e2,22.0.1+a5ff6e246e,22.0.1+a7db719c1a,22.0.1+ba0d97e778,22.0.1+bfe1ee9056,22.0.1+c4e1e0358a,22.0.1+cc34b8281e,22.0.1+d640e2c0fa,22.0.1+d72a2e677a,22.0.1+d9a6b571bd,22.0.1+e485e9761b,22.0.1+ebe8d3385e
LSST Data Management Base Package
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.pipe.base.pipelineIR.ConfigIR Class Reference

Public Member Functions

Dict[str, Union[str, dict, List[str]]] to_primitives (self)
 
ConfigIR formatted (self, ParametersIR parameters)
 
Generator["ConfigIR", None, None] maybe_merge (self, "ConfigIR" other_config)
 
def __eq__ (self, object other)
 

Public Attributes

 file
 

Static Public Attributes

 default_factory
 
 dict
 

Detailed Description

Intermediate representation of configurations read from a pipeline yaml
file.

Definition at line 211 of file pipelineIR.py.

Member Function Documentation

◆ __eq__()

def lsst.pipe.base.pipelineIR.ConfigIR.__eq__ (   self,
object  other 
)

Definition at line 316 of file pipelineIR.py.

316  def __eq__(self, other: object):
317  if not isinstance(other, ConfigIR):
318  return False
319  elif all(getattr(self, attr) == getattr(other, attr) for attr in
320  ("python", "dataId", "file", "rest")):
321  return True
322  else:
323  return False
324 
325 
326 @dataclass
bool all(CoordinateExpr< N > const &expr) noexcept
Return true if all elements are true.

◆ formatted()

ConfigIR lsst.pipe.base.pipelineIR.ConfigIR.formatted (   self,
ParametersIR  parameters 
)
Returns a new ConfigIR object that is formatted according to the
specified parameters

Parameters
----------
parameters : ParametersIR
    Object that contains variable mappings used in substitution.

Returns
-------
config : ConfigIR
    A new ConfigIR object formatted with the input parameters

Definition at line 250 of file pipelineIR.py.

250  def formatted(self, parameters: ParametersIR) -> ConfigIR:
251  """Returns a new ConfigIR object that is formatted according to the
252  specified parameters
253 
254  Parameters
255  ----------
256  parameters : ParametersIR
257  Object that contains variable mappings used in substitution.
258 
259  Returns
260  -------
261  config : ConfigIR
262  A new ConfigIR object formatted with the input parameters
263  """
264  new_config = copy.deepcopy(self)
265  for key, value in new_config.rest.items():
266  if not isinstance(value, str):
267  continue
268  match = re.match("parameters[.](.*)", value)
269  if match and match.group(1) in parameters:
270  new_config.rest[key] = parameters[match.group(1)]
271  if match and match.group(1) not in parameters:
272  warnings.warn(f"config {key} contains value {match.group(0)} which is formatted like a "
273  "Pipeline parameter but was not found within the Pipeline, if this was not "
274  "intentional, check for a typo")
275  return new_config
276 

◆ maybe_merge()

Generator["ConfigIR", None, None] lsst.pipe.base.pipelineIR.ConfigIR.maybe_merge (   self,
"ConfigIR"  other_config 
)
Merges another instance of a `ConfigIR` into this instance if
possible. This function returns a generator that is either self
if the configs were merged, or self, and other_config if that could
not be merged.

Parameters
----------
other_config : `ConfigIR`
    An instance of `ConfigIR` to merge into this instance.

Returns
-------
Generator : `ConfigIR`
    A generator containing either self, or self and other_config if
    the configs could be merged or not respectively.

Definition at line 277 of file pipelineIR.py.

277  def maybe_merge(self, other_config: "ConfigIR") -> Generator["ConfigIR", None, None]:
278  """Merges another instance of a `ConfigIR` into this instance if
279  possible. This function returns a generator that is either self
280  if the configs were merged, or self, and other_config if that could
281  not be merged.
282 
283  Parameters
284  ----------
285  other_config : `ConfigIR`
286  An instance of `ConfigIR` to merge into this instance.
287 
288  Returns
289  -------
290  Generator : `ConfigIR`
291  A generator containing either self, or self and other_config if
292  the configs could be merged or not respectively.
293  """
294  # Verify that the config blocks can be merged
295  if self.dataId != other_config.dataId or self.python or other_config.python or\
296  self.file or other_config.file:
297  yield from (self, other_config)
298  return
299 
300  # create a set of all keys, and verify two keys do not have different
301  # values
302  key_union = self.rest.keys() & other_config.rest.keys()
303  for key in key_union:
304  if self.rest[key] != other_config.rest[key]:
305  yield from (self, other_config)
306  return
307  self.rest.update(other_config.rest)
308 
309  # Combine the lists of override files to load
310  self_file_set = set(self.file)
311  other_file_set = set(other_config.file)
312  self.file = list(self_file_set.union(other_file_set))
313 
314  yield self
315 
daf::base::PropertyList * list
Definition: fits.cc:913
daf::base::PropertySet * set
Definition: fits.cc:912

◆ to_primitives()

Dict[str, Union[str, dict, List[str]]] lsst.pipe.base.pipelineIR.ConfigIR.to_primitives (   self)
Convert to a representation used in yaml serialization

Definition at line 236 of file pipelineIR.py.

236  def to_primitives(self) -> Dict[str, Union[str, dict, List[str]]]:
237  """Convert to a representation used in yaml serialization
238  """
239  accumulate = {}
240  for name in ("python", "dataId", "file"):
241  # if this attribute is thruthy add it to the accumulation
242  # dictionary
243  if getattr(self, name):
244  accumulate[name] = getattr(self, name)
245  # Add the dictionary containing the rest of the config keys to the
246  # # accumulated dictionary
247  accumulate.update(self.rest)
248  return accumulate
249 

Member Data Documentation

◆ default_factory

lsst.pipe.base.pipelineIR.ConfigIR.default_factory
static

Definition at line 225 of file pipelineIR.py.

◆ dict

lsst.pipe.base.pipelineIR.ConfigIR.dict
static

Definition at line 230 of file pipelineIR.py.

◆ file

lsst.pipe.base.pipelineIR.ConfigIR.file

Definition at line 312 of file pipelineIR.py.


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