aistore.sdk.obj.object_reader
aistore.sdk.obj.object_reader
Module Contents
Classes
API
Provide a way to read an object’s contents and attributes, optionally iterating over a stream of content.
Parameters:
ObjectClient — Client for making requests to a specific object in AIS
Size of each data chunk to be fetched from the stream. Defaults to DEFAULT_CHUNK_SIZE.
If provided, use concurrent range-reads with this many workers.
Object metadata attributes.
Make a request to get a stream from the provided object and yield chunks of the stream content.
Returns: None
Generator[bytes, None, None]: An iterator over each chunk of bytes in the object
Use the object client to get a response from AIS and update the reader’s object attributes.
Parameters:
If True, use the requests library stream option to stream the response content.
Defaults to True.
Returns: requests.Response
The response object from the request.
Create a read-only, non-seekable ObjectFileReader instance for streaming object data in chunks.
This file-like object primarily implements the read() method to retrieve data sequentially,
with automatic retry/resumption in case of unexpected stream interruptions (e.g. ChunkedEncodingError,
ConnectionError) or timeouts (e.g. ReadTimeout).
Parameters:
Currently unused; retained for backward compatibility and future enhancements.
Maximum consecutive attempts to resume the stream after interruptions without forward progress. Defaults to 5.
Returns: BufferedIOBase
A read-only, non-seekable file-like object for streaming object content.
Raises:
ValueError: Ifmax_resumeis invalid (must be a non-negative integer).
Make a head request to AIS to update and return only object attributes.
Returns: ObjectAttributes
ObjectAttributes containing metadata for this object.
Return the raw byte stream of the object content.
Deprecated
Will be removed in 3.0. Use stream() instead to access the full response and response.raw.
Returns: Any
requests.Response.raw: Raw byte stream of the object content.
Read all object content into memory.
Returns: Union[bytes, ParallelBuffer ]
When called without num_workers (single-stream GET).
Return the full response with an open stream of object content.
The caller must close the response when finished, preferably using a context manager. Access headers, raw bytes via response.raw, or chunks via response.iter_content().
Example
>>> with obj.get_reader().stream() as response: … data = response.raw.read()
Returns: requests.Response
requests.Response: Response requested with stream=True.