MultiblockWriter¶
- class lsst.pipe.base.quantum_graph.MultiblockWriter(stream: ~typing.IO[bytes], int_size: int, file_size: int = 0, addresses: dict[uuid.UUID, lsst.pipe.base.quantum_graph._multiblock.Address] = <factory>)¶
Bases:
objectA helper object for writing multi-block files.
Attributes Summary
Running size of the full file.
Methods Summary
open_in_zip(zf, name, int_size)Open a writer for a file in a zip archive.
write_bytes(id, data)Write raw bytes to the multi-block file.
write_model(id, model, compressor)Write raw bytes to the multi-block file.
Attributes Documentation
Methods Documentation
- classmethod open_in_zip(zf: zipfile.ZipFile, name: str, int_size: int) Iterator[MultiblockWriter]¶
Open a writer for a file in a zip archive.
- Parameters:
- zf
zipfile.ZipFile Zip archive to add the file to.
- name
str Base name for the multi-block file; an extension will be added.
- int_size
int Number of bytes to use for all integers.
- zf
- Returns:
- writer
contextlib.AbstractContextManager[MultiblockWriter] Context manager that returns a writer when entered.
- writer
- write_model(id: UUID, model: BaseModel, compressor: Compressor) Address¶
Write raw bytes to the multi-block file.
- Parameters:
- id
uuid.UUID Unique ID of the object described by this block.
- model
pydantic.BaseModel Model to convert to JSON and compress.
- compressor
Compressor Object with a
compressmethod that takes and returnsbytes.
- id
- Returns:
- address
Address Address of the bytes just written.
- address