FileTemplates¶
- class lsst.daf.butler.FileTemplates(config: FileTemplatesConfig | str, default: str | None = None, *, universe: DimensionUniverse)¶
- Bases: - object- Collection of - FileTemplatetemplates.- Parameters:
- configFileTemplatesConfigorstr
- Load configuration. 
- defaultstr, optional
- If not - None, a default template to use if no template has been specified explicitly in the configuration.
- universeDimensionUniverse
- The set of all known dimensions, used to normalize any lookup keys involving dimensions. 
 
- config
 - 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 a- DatasetRefcontains 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 boolean- False.- The config is parsed using the function - processLookupConfigs.- Attributes Summary - Configuration key associated with the default template. - Return collection of templates indexed by lookup key ( - dict).- Methods Summary - Retrieve the look up keys for all the template entries. - getTemplate(entity)- Retrieve the - FileTemplateassociated with the dataset type.- getTemplateWithMatch(entity)- Retrieve the - FileTemplateassociated with the dataset type.- validateTemplates(entities[, logFailures])- Validate the templates. - Attributes Documentation - defaultKey = LookupKey(name='default',)¶
- Configuration key associated with the default template. 
 - Methods Documentation - getTemplate(entity: DatasetType | DatasetRef | StorageClass) FileTemplate¶
- 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:
- entityDatasetType,DatasetRef, orStorageClass
- Instance to use to look for a corresponding template. A - DatasetTypename or a- StorageClassname will be used depending on the supplied entity. Priority is given to a- DatasetTypename. Supports instrument override if a- DatasetRefis provided configured with an- instrumentvalue for the data ID.
 
- entity
- Returns:
- templateFileTemplate
- Template instance to use with that dataset type. 
 
- template
- Raises:
- KeyError
- Raised if no template could be located for this Dataset type. 
 
 
 - getTemplateWithMatch(entity: DatasetRef | DatasetType | StorageClass) Tuple[LookupKey, FileTemplate]¶
- Retrieve the - FileTemplateassociated with the dataset type.- Also retrieves the lookup key that was a match for this template. - 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:
- entityDatasetType,DatasetRef, orStorageClass
- Instance to use to look for a corresponding template. A - DatasetTypename or a- StorageClassname will be used depending on the supplied entity. Priority is given to a- DatasetTypename. Supports instrument override if a- DatasetRefis provided configured with an- instrumentvalue for the data ID.
 
- entity
- Returns:
- matchKeyLookupKey
- The key that resulted in the successful match. 
- templateFileTemplate
- Template instance to use with that dataset type. 
 
- matchKey
- Raises:
- KeyError
- Raised if no template could be located for this Dataset type. 
 
 
 - validateTemplates(entities: Iterable[DatasetType | DatasetRef | StorageClass], logFailures: bool = False) None¶
- Validate the templates. - Retrieves the template associated with each dataset type and validates the dimensions against the template. - Parameters:
- entitiesDatasetType,DatasetRef, orStorageClass
- Entities to validate against the matching templates. Can be differing types. 
- logFailuresbool, optional
- If - True, output a log message for every validation error detected.
 
- entities
- Raises:
- FileTemplateValidationError
- Raised if an entity failed validation. 
 
 - Notes - See - FileTemplate.validateTemplate()for details on the validation.