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 | List of all members
lsst.pipe.base.pipeline.PipelineDatasetTypes Class Reference

Public Member Functions

PipelineDatasetTypes fromPipeline (cls, pipeline, *Registry registry)
 

Detailed Description

An immutable struct that classifies the dataset types used in a
`Pipeline`.

Definition at line 769 of file pipeline.py.

Member Function Documentation

◆ fromPipeline()

PipelineDatasetTypes lsst.pipe.base.pipeline.PipelineDatasetTypes.fromPipeline (   cls,
  pipeline,
*Registry  registry 
)
Extract and classify the dataset types from all tasks in a
`Pipeline`.

Parameters
----------
pipeline: `Pipeline`
    An ordered collection of tasks that can be run together.
registry: `Registry`
    Registry used to construct normalized `DatasetType` objects and
    retrieve those that are incomplete.

Returns
-------
types: `PipelineDatasetTypes`
    The dataset types used by this `Pipeline`.

Raises
------
ValueError
    Raised if Tasks are inconsistent about which datasets are marked
    prerequisite.  This indicates that the Tasks cannot be run as part
    of the same `Pipeline`.

Definition at line 835 of file pipeline.py.

835  def fromPipeline(cls, pipeline, *, registry: Registry) -> PipelineDatasetTypes:
836  """Extract and classify the dataset types from all tasks in a
837  `Pipeline`.
838 
839  Parameters
840  ----------
841  pipeline: `Pipeline`
842  An ordered collection of tasks that can be run together.
843  registry: `Registry`
844  Registry used to construct normalized `DatasetType` objects and
845  retrieve those that are incomplete.
846 
847  Returns
848  -------
849  types: `PipelineDatasetTypes`
850  The dataset types used by this `Pipeline`.
851 
852  Raises
853  ------
854  ValueError
855  Raised if Tasks are inconsistent about which datasets are marked
856  prerequisite. This indicates that the Tasks cannot be run as part
857  of the same `Pipeline`.
858  """
859  allInputs = NamedValueSet()
860  allOutputs = NamedValueSet()
861  allInitInputs = NamedValueSet()
862  allInitOutputs = NamedValueSet()
863  prerequisites = NamedValueSet()
864  byTask = dict()
865  if isinstance(pipeline, Pipeline):
866  pipeline = pipeline.toExpandedPipeline()
867  for taskDef in pipeline:
868  thisTask = TaskDatasetTypes.fromTaskDef(taskDef, registry=registry)
869  allInitInputs |= thisTask.initInputs
870  allInitOutputs |= thisTask.initOutputs
871  allInputs |= thisTask.inputs
872  prerequisites |= thisTask.prerequisites
873  allOutputs |= thisTask.outputs
874  byTask[taskDef.label] = thisTask
875  if not prerequisites.isdisjoint(allInputs):
876  raise ValueError("{} marked as both prerequisites and regular inputs".format(
877  {dt.name for dt in allInputs & prerequisites}
878  ))
879  if not prerequisites.isdisjoint(allOutputs):
880  raise ValueError("{} marked as both prerequisites and outputs".format(
881  {dt.name for dt in allOutputs & prerequisites}
882  ))
883  # Make sure that components which are marked as inputs get treated as
884  # intermediates if there is an output which produces the composite
885  # containing the component
886  intermediateComponents = NamedValueSet()
887  intermediateComposites = NamedValueSet()
888  outputNameMapping = {dsType.name: dsType for dsType in allOutputs}
889  for dsType in allInputs:
890  # get the name of a possible component
891  name, component = dsType.nameAndComponent()
892  # if there is a component name, that means this is a component
893  # DatasetType, if there is an output which produces the parent of
894  # this component, treat this input as an intermediate
895  if component is not None:
896  if name in outputNameMapping:
897  if outputNameMapping[name].dimensions != dsType.dimensions:
898  raise ValueError(f"Component dataset type {dsType.name} has different "
899  f"dimensions ({dsType.dimensions}) than its parent "
900  f"({outputNameMapping[name].dimensions}).")
901  composite = DatasetType(name, dsType.dimensions, outputNameMapping[name].storageClass,
902  universe=registry.dimensions)
903  intermediateComponents.add(dsType)
904  intermediateComposites.add(composite)
905 
906  def checkConsistency(a: NamedValueSet, b: NamedValueSet):
907  common = a.names & b.names
908  for name in common:
909  if a[name] != b[name]:
910  raise ValueError(f"Conflicting definitions for dataset type: {a[name]} != {b[name]}.")
911 
912  checkConsistency(allInitInputs, allInitOutputs)
913  checkConsistency(allInputs, allOutputs)
914  checkConsistency(allInputs, intermediateComposites)
915  checkConsistency(allOutputs, intermediateComposites)
916 
917  def frozen(s: NamedValueSet) -> NamedValueSet:
918  s.freeze()
919  return s
920 
921  return cls(
922  initInputs=frozen(allInitInputs - allInitOutputs),
923  initIntermediates=frozen(allInitInputs & allInitOutputs),
924  initOutputs=frozen(allInitOutputs - allInitInputs),
925  inputs=frozen(allInputs - allOutputs - intermediateComponents),
926  intermediates=frozen(allInputs & allOutputs | intermediateComponents),
927  outputs=frozen(allOutputs - allInputs - intermediateComposites),
928  prerequisites=frozen(prerequisites),
929  byTask=MappingProxyType(byTask), # MappingProxyType -> frozen view of dict for immutability
930  )
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

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