get_object_bytes#

torch_brain.utils.s3.get_object_bytes(bucket, key, *, s3_client=None)[source]#

Read a single S3 object into memory.

Parameters:
  • bucket (str) – S3 bucket name

  • key (str) – Object key to read

  • s3_client (Optional[BaseClient]) – Optional pre-configured S3 client

Return type:

bytes | None

Returns:

Object contents as bytes, or None if the object does not exist on S3.

Raises:
  • RuntimeError – If the read fails for a reason other than the object being absent.

  • ImportError – If boto3/botocore is not installed.