FileTemplates¶
-
class
lsst.daf.butler.
FileTemplates
(config: Union[FileTemplatesConfig, str], default: Optional[str] = None, *, universe: DimensionUniverse)¶ Bases:
object
Collection of
FileTemplate
templates.Parameters: - config :
FileTemplatesConfig
orstr
Load configuration.
- default :
str
, optional If not
None
, a default template to use if no template has been specified explicitly in the configuration.- universe :
DimensionUniverse
The set of all known dimensions, used to normalize any lookup keys involving dimensions.
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 aDatasetRef
contains 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
.Attributes Summary
defaultKey
Configuration key associated with the default template. templates
Collection of templates indexed by lookup key ( dict
).Methods Summary
getLookupKeys
()Retrieve the look up keys for all the template entries. getTemplate
(entity, DatasetRef, StorageClass])Retrieve the FileTemplate
associated with the dataset type.getTemplateWithMatch
(entity, DatasetType, …)Retrieve the FileTemplate
associated with the dataset type along with the lookup key that was a match for this template.validateTemplates
(entities, DatasetRef, …)Retrieve the template associated with each dataset type and validate the dimensions against the template. Attributes Documentation
-
defaultKey
= LookupKey(name='default',)¶ Configuration key associated with the default template.
Methods Documentation
-
getLookupKeys
() → Set[lsst.daf.butler.core.configSupport.LookupKey]¶ Retrieve the look up keys for all the template entries.
Returns:
-
getTemplate
(entity: Union[DatasetType, DatasetRef, StorageClass]) → FileTemplate¶ Retrieve the
FileTemplate
associated 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
DatasetType
name or aStorageClass
name will be used depending on the supplied entity. Priority is given to aDatasetType
name. Supports instrument override if aDatasetRef
is provided configured with aninstrument
value 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 :
-
getTemplateWithMatch
(entity: Union[DatasetRef, DatasetType, StorageClass]) → Tuple[LookupKey, FileTemplate]¶ Retrieve the
FileTemplate
associated with the dataset type along with 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: - entity :
DatasetType
,DatasetRef
, orStorageClass
Instance to use to look for a corresponding template. A
DatasetType
name or aStorageClass
name will be used depending on the supplied entity. Priority is given to aDatasetType
name. Supports instrument override if aDatasetRef
is provided configured with aninstrument
value for the data ID.
Returns: - matchKey :
LookupKey
The key that resulted in the successful match.
- template :
FileTemplate
Template instance to use with that dataset type.
Raises: - KeyError
Raised if no template could be located for this Dataset type.
- entity :
-
validateTemplates
(entities: Iterable[Union[DatasetType, DatasetRef, StorageClass]], logFailures: bool = False) → None¶ 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. Can be differing types.
- logFailures :
bool
, optional If
True
, output a log message for every validation error detected.
Raises: - FileTemplateValidationError
Raised if an entity failed validation.
Notes
See
FileTemplate.validateTemplate()
for details on the validation.- entities :
- config :