BadWriteFormatter¶
- class lsst.daf.butler.tests.BadWriteFormatter(file_descriptor: FileDescriptor, *, ref: DatasetRef, write_parameters: Mapping[str, Any] | None = None, write_recipes: Mapping[str, Any] | None = None, **kwargs: Any)¶
Bases:
YamlFormatterA formatter that never works but does leave a file behind.
Attributes Summary
Declare whether
read_from_local_fileis available to this formatter.Declare whether
read_from_streamis available to this formatter.Declare whether
read_from_uriis available to this formatter.Methods Summary
read_from_uri(uri[, component, expected_size])Read a dataset from a URI that can be local or remote.
write_direct(in_memory_dataset, uri[, ...])Write empty file and immediately fail.
Attributes Documentation
- can_read_from_local_file: ClassVar[bool] = False¶
Declare whether
read_from_local_fileis available to this formatter.
- can_read_from_stream: ClassVar[bool] = False¶
Declare whether
read_from_streamis available to this formatter.
- can_read_from_uri: ClassVar[bool] = False¶
Declare whether
read_from_uriis available to this formatter.
Methods Documentation
- read_from_uri(uri: ResourcePath, component: str | None = None, expected_size: int = -1) Any¶
Read a dataset from a URI that can be local or remote.
- Parameters:
- uri
lsst.resources.ResourcePath URI to use to read the dataset. This URI can be local or remote and can refer to the actual resource or to a locally cached file.
- component
strorNone, optional The component to be read from the dataset.
- expected_size
int, optional If known, the expected size of the resource to read. This can be
-1indicates the file size is not known.
- uri
- Returns:
- in_memory_dataset
objectorNotImplemented The Python object read from the resource or
NotImplemented.
- in_memory_dataset
- Raises:
- lsst.daf.butler.FormatterNotImplementedError
Raised if there is no support for direct reads from a, possibly, remote URI.
Notes
This method is only called if the class property
can_read_from_uriis set toTrue.It is possible that a cached local file will be given to this method even if it was originally a remote URI. This can happen if the original write resulted in the file being added to the local cache.
If the full file is being read this file will not be added to the local cache. Consider returning
NotImplementedin this situation, for example if there are no parameters or component specified, and allowing the system to fall back to callingread_from_local_file(which will populate the cache if configured to do so).
- write_direct(in_memory_dataset: Any, uri: ResourcePath, cache_manager: AbstractDatastoreCacheManager | None = None) bool¶
Write empty file and immediately fail.
- Parameters:
- in_memory_dataset
typing.Any The Python object to serialize.
- uri
lsst.resources.ResourcePath The location to write the content.
- cache_manager
AbstractDatastoreCacheManager Cache manager. Unused.
- in_memory_dataset
- Raises:
- RuntimeError
Raised every time specifically for testing this scenario.