s3torchconnector.s3reader.sequential ==================================== .. py:module:: s3torchconnector.s3reader.sequential Classes ------- .. autoapisummary:: s3torchconnector.s3reader.sequential.SequentialS3Reader Module Contents --------------- .. py:class:: SequentialS3Reader(bucket: str, key: str, get_object_info: Callable[[], Union[s3torchconnectorclient._mountpoint_s3_client.ObjectInfo, s3torchconnectorclient._mountpoint_s3_client.HeadObjectResult]], get_stream: Callable[[], s3torchconnectorclient._mountpoint_s3_client.GetObjectStream]) Bases: :py:obj:`s3torchconnector.s3reader.s3reader.S3Reader` Sequential S3 reader implementation Maintains an internal buffer for efficient sequential reads and repeated access. Optimal for most use cases, including full object reads. .. py:property:: bucket :type: str .. py:property:: key :type: str .. py:method:: prefetch() -> None Start fetching data from S3. :raises S3Exception: An error occurred accessing S3. .. py:method:: readinto(buf) -> int Read up to len(buf) bytes into a pre-allocated, writable bytes-like object buf. Return the number of bytes read. If no bytes are available, zero is returned. :param buf: writable bytes-like object :returns: numer of bytes read or zero, if no bytes available :rtype: int .. py:method:: read(size: Optional[int] = None) -> bytes Read up to size bytes from the object and return them. If size is zero or positive, read that many bytes from S3, or until the end of the object. If size is None or negative, read the entire file. :param size: how many bytes to read. :type size: int | None :returns: Bytes read from S3 Object :rtype: bytes :raises S3Exception: An error occurred accessing S3. .. py:method:: seek(offset: int, whence: int = SEEK_SET, /) -> int Change the stream position to the given byte offset, interpreted relative to whence. When seeking beyond the end of the file, always stay at EOF. Seeking before the start of the file results in a ValueError. :param offset: How many bytes to seek relative to whence. :type offset: int :param whence: One of SEEK_SET, SEEK_CUR, and SEEK_END. Default: SEEK_SET :type whence: int :returns: Current position of the stream :rtype: int :raises S3Exception: An error occurred accessing S3. .. py:method:: tell() -> int :returns: Current stream position. :rtype: int