read#
- lsst.images.serialization.read(path: str | ParseResult | ResourcePath | Path, cls: type[T], **kwargs: Any) T#
- lsst.images.serialization.read(path: str | ParseResult | ResourcePath | Path, cls: None = None, **kwargs: Any) Any
Read an archive whose in-memory type is inferred from its schema.
Dispatches to the appropriate backend based on
path’s extension, resolves the registered in-memory type from the file’s schema, and returns the fully deserialized object. Schema-version compatibility is enforced when the model validates the on-disk tree, viamin_read_version.This is the convenient way to read a whole object. To read individual components, or to reach the metadata and butler info stored alongside the object, use
openinstead.Parameters#
- path
File to read; convertible to
lsst.resources.ResourcePath.- cls
Optional expected in-memory type. When given, the file’s schema is checked against
clsand the deserialized object is validated withisinstance(raisingTypeErrorotherwise), and the static return type isT.- **kwargs
Type-specific keyword arguments forwarded to the object’s
deserialize(e.g.bboxfor an image subset read). Mis-targeted arguments surface asTypeError. Backend-specific open options (e.g.page_size) are not accepted here; useopenfor those.
Returns#
- object
The deserialized object.
Raises#
- ValueError
Raised by
backend_for_pathif the file extension is not recognized.- ArchiveReadError
Raised when the file’s
schema_nameis not registered, or propagated from the model’smin_read_versioncheck onmodel_validate*.- TypeError
Raised when
clsis given and the file’s schema or the deserialized object is not compatible with it.