FileTemplate¶
- class lsst.daf.butler.FileTemplate(template: str)¶
- Bases: - object- Format a path template into a fully expanded path. - Parameters:
- templatestr
- Template string. 
 
- template
- Raises:
- FileTemplateValidationError
- Raised if the template fails basic validation. 
 
 - Notes - The templates use the standard Format Specification Mini-Language with the caveat that only named fields can be used. The field names are taken from the Dimensions along with several additional fields: - datasetType: - str,- DatasetType.name
- component: - str, name of the StorageClass component
- run: - str, name of the run this dataset was added with
 - runmust always be provided to ensure unique paths.- More detailed information can be requested from dimensions by using a dot notation, so - visit.namewould use the name of the visit and- detector.name_in_raftwould use the name of the detector within the raft.- The mini-language is extended to understand a “?” in the format specification. This indicates that a field is optional. If that Dimension is missing the field, along with the text before the field, unless it is a path separator, will be removed from the output path. - By default any “/” in a dataId value will be replaced by “_” to prevent unexpected directories being created in the path. If the “/” should be retained then a special “/” format specifier can be included in the template. - Attributes Summary - Fields related to the supplied dataset, not a dimension. - A set of fields, one of which must be present in a template. - Set of special fields that are available independently of the defined Dimensions. - Methods Summary - fields([optionals, specials, subfields])- Return the field names used in this template. - format(ref)- Format a template string into a full path. - validateTemplate(entity)- Compare the template against supplied entity that wants to use it. - Attributes Documentation - datasetFields = {'component', 'datasetType'}¶
- Fields related to the supplied dataset, not a dimension. 
 - mandatoryFields = {'id', 'run'}¶
- A set of fields, one of which must be present in a template. 
 - specialFields = {'component', 'datasetType', 'id', 'run'}¶
- Set of special fields that are available independently of the defined Dimensions. 
 - Methods Documentation - fields(optionals: bool = False, specials: bool = False, subfields: bool = False) Set[str]¶
- Return the field names used in this template. - Parameters:
- Returns:
- namesset
- Names of fields used in this template 
 
- names
 - Notes - The returned set will include the special values such as - datasetTypeand- component.
 - format(ref: DatasetRef) str¶
- Format a template string into a full path. - Parameters:
- refDatasetRef
- The dataset to be formatted. 
 
- ref
- Returns:
- pathstr
- Expanded path. 
 
- path
- Raises:
- KeyError
- Raised if the requested field is not defined and the field is not optional. Or, - componentis specified but “component” was not part of the template.
- RuntimeError
- Raised if a template uses dimension record metadata but no records are attached to the - DatasetRef.
 
 
 - validateTemplate(entity: DatasetRef | DatasetType | StorageClass | None) None¶
- Compare the template against supplied entity that wants to use it. - Parameters:
- entityDatasetType,DatasetRef, orStorageClass
- Entity to compare against template. If - Noneis given only very basic validation of templates will be performed.
 
- entity
- Raises:
- FileTemplateValidationError
- Raised if the template is inconsistent with the supplied entity. 
 
 - Notes - Validation will always include a check that mandatory fields are present and that at least one field refers to a dimension. If the supplied entity includes a - DimensionGraphthen it will be used to compare the available dimensions with those specified in the template.