FileTemplates¶
-
class
lsst.daf.butler.FileTemplates(config, default=None)¶ Bases:
objectCollection of
FileTemplatetemplates.Parameters: - config :
FileTemplatesConfigorstr Load configuration.
- default :
str, optional If not
None, a default template to use if no template has been specified explicitly in the configuration.
Notes
The configuration can include one level of hierarchy where an instrument-specific section can be defined to override more general template specifications. This is represented in YAML using a key of form
instrument<name>which can then define templates that will be returned if aDatasetRefcontains a matching instrument name in the data ID.A default fallback template can be specified using the key
default. Defaulting can be disabled in a child configuration by defining the value to be an empty string or a booleanFalse.The config is parsed using the function
processLookupConfigs.Methods Summary
getTemplate(entity)Retrieve the FileTemplateassociated with the dataset type.normalizeDimensions(universe)Normalize template lookups that use dimensions. validateTemplate(*entities)Retrieve the template associated with each dataset type and validate the dimensions against the template. Methods Documentation
-
getTemplate(entity)¶ Retrieve the
FileTemplateassociated with the dataset type.If the lookup name corresponds to a component the base name for the component will be examined if the full component name does not match.
Parameters: - entity :
DatasetType,DatasetRef, orStorageClass Instance to use to look for a corresponding template. A
DatasetTypename or aStorageClassname will be used depending on the supplied entity. Priority is given to aDatasetTypename. Supports instrument override if aDatasetRefis provided configured with aninstrumentvalue for the data ID.
Returns: - template :
FileTemplate Template instance to use with that dataset type.
Raises: - KeyError
Raised if no template could be located for this Dataset type.
- entity :
-
normalizeDimensions(universe)¶ Normalize template lookups that use dimensions.
Parameters: - universe :
DimensionUniverse The set of all known dimensions. If
None, returns without action.
Raises: - ValueError
Raised if a key exists where a dimension is not part of the
universe.
Notes
Goes through all registered templates, and for keys that include dimensions, rewrites those keys to use a verified set of dimensions.
Returns without action if the template keys have already been normalized.
- universe :
-
validateTemplate(*entities)¶ Retrieve the template associated with each dataset type and validate the dimensions against the template.
Parameters: - *entities :
DatasetType,DatasetRef, orStorageClass Entities to validate against the matching templates.
Raises: - KeyError
Raised if no template could be found for the supplied entity.
- FileTemplateValidationError
Raised if an entity failed validation.
Notes
See
FileTemplate.validateTemplate()for details on the validation.- *entities :
- config :