download_object#
- torch_brain.utils.s3.download_object(bucket, key, target_path, *, redownload=False, s3_client=None)[source]#
Download a single S3 object to a local file.
- Parameters:
bucket (
str) – S3 bucket namekey (
str) – Object key to downloadtarget_path (
Path) – Local file path to write toredownload (
bool) – IfFalse(default), return an existing local file as-is. IfTrue, re-download and overwrite any existing local file. If the object is missing on S3, any existing local file is removed.s3_client (
Optional[BaseClient]) – Optional pre-configured S3 client
- Return type:
- Returns:
Path to the downloaded or existing local file, or
Noneif the object does not exist on S3.- Raises:
RuntimeError – If the download fails for a reason other than the object being absent.
ImportError – If boto3/botocore is not installed.