Skip to content
heliaEDGE
Reference
HELIA

aws

AWS Cloud Utility API

This module provides utility functions to interact with AWS services.

Functions

Name Description
download_s3_file Download a file from S3
download_s3_object Download an object from S3
download_s3_prefix Download all objects under an S3 prefix into a local directory
download_s3_objects Download all objects in a S3 bucket with a given prefix (deprecated)

Machine-readable model

function

Download a file from S3

helia_edge/utils/aws.py:47

download_s3_file(
key: str,
dst: Path,
bucket: str,
client: boto3.client = None,
checksum: str = 'size',
config: Config | None = Config(signature_version=UNSIGNED),
) -> bool

Download a file from S3

Parameters of download_s3_file
NameTypeDefaultDescription
keystrRequiredObject key
dstPathRequiredDestination path
bucketstrRequiredBucket name
clientboto3.clientNoneS3 client
checksumstr'size'Checksum type. Defaults to "size".
configConfigConfig(signature_version=UNSIGNED)Boto3 config. Defaults to Config(signature_version=UNSIGNED).
Returns of download_s3_file
ValueTypeDescription
boolboolTrue if file was downloaded, False if already exists
function

Download an object from S3

helia_edge/utils/aws.py:96

download_s3_object(
item: dict[str, str],
dst: Path,
bucket: str,
client: boto3.client = None,
checksum: str = 'size',
config: Config | None = Config(signature_version=UNSIGNED),
) -> bool

Download an object from S3

Parameters of download_s3_object
NameTypeDefaultDescription
itemdict[str, str]RequiredObject metadata
dstPathRequiredDestination path
bucketstrRequiredBucket name
clientboto3.clientNoneS3 client
checksumstr'size'Checksum type. Defaults to "size".
configConfigConfig(signature_version=UNSIGNED)Boto3 config. Defaults to Config(signature_version=UNSIGNED).
Returns of download_s3_object
ValueTypeDescription
boolboolTrue if file was downloaded, False if already exists
function

Download all objects in a S3 bucket with a given prefix.

helia_edge/utils/aws.py:150

download_s3_objects(
bucket: str,
prefix: str,
dst: Path,
checksum: str = 'size',
progress: bool = True,
num_workers: int | None = None,
config: Config | None = Config(signature_version=UNSIGNED),
)

Download all objects in a S3 bucket with a given prefix.

.. deprecated:: Use :func:download_s3_prefix instead. This function preserves the full S3 key (including the prefix) when building local paths, which causes files to be nested one level too deep when dst already contains the prefix directory. The replacement strips the prefix so that dst is always the root of the downloaded tree.

Parameters of download_s3_objects
NameTypeDefaultDescription
bucketstrRequiredBucket name
prefixstrRequiredPrefix to filter objects
dstPathRequiredDestination directory
checksumstr'size'Checksum type. Defaults to "size".
progressboolTrueShow progress bar. Defaults to True.
num_workersint | NoneNoneNumber of workers. Defaults to None.
configConfig | NoneConfig(signature_version=UNSIGNED)Boto3 config. Defaults to Config(signature_version=UNSIGNED).
function

Download all objects under an S3 prefix into a local directory.

helia_edge/utils/aws.py:257

download_s3_prefix(
bucket: str,
prefix: str,
dst: Path,
checksum: str = 'size',
progress: bool = True,
num_workers: int | None = None,
config: Config | None = Config(signature_version=UNSIGNED),
) -> int

Download all objects under an S3 prefix into a local directory.

Unlike :func:download_s3_objects, this function strips the prefix from each object key before joining it with dst, so that dst becomes the root of the downloaded tree.

Example::

S3 objects: s3://my-bucket/datasets/ptbxl/00001.h5

Section titled “S3 objects: s3://my-bucket/datasets/ptbxl/00001.h5”

download_s3_prefix( bucket=“my-bucket”, prefix=“datasets/ptbxl”, dst=Path(“./data/ptbxl”), )

Parameters of download_s3_prefix
NameTypeDefaultDescription
bucketstrRequiredBucket name.
prefixstrRequiredKey prefix to filter objects. A trailing ``/`` is added automatically if missing.
dstPathRequiredLocal directory that will mirror the contents found under *prefix*.
checksumstr'size'Checksum strategy (``"size"`` or ``"md5"``). Defaults to ``"size"``.
progressboolTrueShow a ``tqdm`` progress bar. Defaults to ``True``.
num_workersint | NoneNoneThread-pool size. ``None`` uses the :class:`~concurrent.futures.ThreadPoolExecutor` default.
configConfig | NoneConfig(signature_version=UNSIGNED)Boto3 client config. Defaults to unsigned requests.
Returns of download_s3_prefix
ValueTypeDescription
intintNumber of objects downloaded (excludes skipped / up-to-date).