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.connections.PipelineTaskConnectionsMetaclass Class Reference
Inheritance diagram for lsst.pipe.base.connections.PipelineTaskConnectionsMetaclass:
lsst.pipe.base.connections.PipelineTaskConnections lsst.meas.base.forcedPhotCcd.ForcedPhotCcdConnections lsst.pipe.tasks.deblendCoaddSourcesPipeline.DeblendCoaddSourceSingleConnections lsst.pipe.tasks.deblendCoaddSourcesPipeline.DeblendCoaddSourcesMultiConnections lsst.pipe.tasks.insertFakes.InsertFakesConnections lsst.pipe.tasks.mergeDetections.MergeDetectionsConnections lsst.pipe.tasks.mergeMeasurements.MergeMeasurementsConnections lsst.pipe.tasks.multiBand.DetectCoaddSourcesConnections lsst.pipe.tasks.processCcdWithFakes.ProcessCcdWithFakesConnections

Public Member Functions

def __prepare__ (name, bases, **kwargs)
 
def __new__ (cls, name, bases, dct, **kwargs)
 
def __init__ (cls, name, bases, dct, **kwargs)
 

Detailed Description

Metaclass used in the declaration of PipelineTaskConnections classes

Definition at line 96 of file connections.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pipe.base.connections.PipelineTaskConnectionsMetaclass.__init__ (   cls,
  name,
  bases,
  dct,
**  kwargs 
)

Definition at line 187 of file connections.py.

187  def __init__(cls, name, bases, dct, **kwargs):
188  # This overrides the default init to drop the kwargs argument. Python
189  # metaclasses will have this argument set if any kwargs are passes at
190  # class construction time, but should be consumed before calling
191  # __init__ on the type metaclass. This is in accordance with python
192  # documentation on metaclasses
193  super().__init__(name, bases, dct)
194 
195 

Member Function Documentation

◆ __new__()

def lsst.pipe.base.connections.PipelineTaskConnectionsMetaclass.__new__ (   cls,
  name,
  bases,
  dct,
**  kwargs 
)

Definition at line 110 of file connections.py.

110  def __new__(cls, name, bases, dct, **kwargs):
111  dimensionsValueError = TypeError("PipelineTaskConnections class must be created with a dimensions "
112  "attribute which is an iterable of dimension names")
113 
114  if name != 'PipelineTaskConnections':
115  # Verify that dimensions are passed as a keyword in class
116  # declaration
117  if 'dimensions' not in kwargs:
118  for base in bases:
119  if hasattr(base, 'dimensions'):
120  kwargs['dimensions'] = base.dimensions
121  break
122  if 'dimensions' not in kwargs:
123  raise dimensionsValueError
124  try:
125  if isinstance(kwargs['dimensions'], str):
126  raise TypeError("Dimensions must be iterable of dimensions, got str,"
127  "possibly omitted trailing comma")
128  if not isinstance(kwargs['dimensions'], typing.Iterable):
129  raise TypeError("Dimensions must be iterable of dimensions")
130  dct['dimensions'] = set(kwargs['dimensions'])
131  except TypeError as exc:
132  raise dimensionsValueError from exc
133  # Lookup any python string templates that may have been used in the
134  # declaration of the name field of a class connection attribute
135  allTemplates = set()
136  stringFormatter = string.Formatter()
137  # Loop over all connections
138  for obj in dct['allConnections'].values():
139  nameValue = obj.name
140  # add all the parameters to the set of templates
141  for param in stringFormatter.parse(nameValue):
142  if param[1] is not None:
143  allTemplates.add(param[1])
144 
145  # look up any template from base classes and merge them all
146  # together
147  mergeDict = {}
148  for base in bases[::-1]:
149  if hasattr(base, 'defaultTemplates'):
150  mergeDict.update(base.defaultTemplates)
151  if 'defaultTemplates' in kwargs:
152  mergeDict.update(kwargs['defaultTemplates'])
153 
154  if len(mergeDict) > 0:
155  kwargs['defaultTemplates'] = mergeDict
156 
157  # Verify that if templated strings were used, defaults were
158  # supplied as an argument in the declaration of the connection
159  # class
160  if len(allTemplates) > 0 and 'defaultTemplates' not in kwargs:
161  raise TypeError("PipelineTaskConnection class contains templated attribute names, but no "
162  "defaut templates were provided, add a dictionary attribute named "
163  "defaultTemplates which contains the mapping between template key and value")
164  if len(allTemplates) > 0:
165  # Verify all templates have a default, and throw if they do not
166  defaultTemplateKeys = set(kwargs['defaultTemplates'].keys())
167  templateDifference = allTemplates.difference(defaultTemplateKeys)
168  if templateDifference:
169  raise TypeError(f"Default template keys were not provided for {templateDifference}")
170  # Verify that templates do not share names with variable names
171  # used for a connection, this is needed because of how
172  # templates are specified in an associated config class.
173  nameTemplateIntersection = allTemplates.intersection(set(dct['allConnections'].keys()))
174  if len(nameTemplateIntersection) > 0:
175  raise TypeError(f"Template parameters cannot share names with Class attributes"
176  f" (conflicts are {nameTemplateIntersection}).")
177  dct['defaultTemplates'] = kwargs.get('defaultTemplates', {})
178 
179  # Convert all the connection containers into frozensets so they cannot
180  # be modified at the class scope
181  for connectionName in ("inputs", "prerequisiteInputs", "outputs", "initInputs", "initOutputs"):
182  dct[connectionName] = frozenset(dct[connectionName])
183  # our custom dict type must be turned into an actual dict to be used in
184  # type.__new__
185  return super().__new__(cls, name, bases, dict(dct))
186 
daf::base::PropertySet * set
Definition: fits.cc:912

◆ __prepare__()

def lsst.pipe.base.connections.PipelineTaskConnectionsMetaclass.__prepare__ (   name,
  bases,
**  kwargs 
)

Definition at line 99 of file connections.py.

99  def __prepare__(name, bases, **kwargs): # noqa: 805
100  # Create an instance of our special dict to catch and track all
101  # variables that are instances of connectionTypes.BaseConnection
102  # Copy any existing connections from a parent class
103  dct = PipelineTaskConnectionDict()
104  for base in bases:
105  if isinstance(base, PipelineTaskConnectionsMetaclass):
106  for name, value in base.allConnections.items():
107  dct[name] = value
108  return dct
109 

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