runway.s3_utils module¶
Utility functions for S3.
- runway.s3_utils.delete_bucket(bucket_name: str, region: str = 'us-east-1', session: Session | None = None) None [source]¶
Delete bucket.
- runway.s3_utils.does_bucket_exist(bucket_name: str, region: str = 'us-east-1', session: Session | None = None) bool [source]¶
Check if bucket exists in S3.
- runway.s3_utils.does_s3_object_exist(bucket: str, key: str, session: Session | None = None, region: str = 'us-east-1') bool [source]¶
Determine if object exists on s3.
- runway.s3_utils.download(bucket: str, key: str, file_path: str, session: Session | None = None) str [source]¶
Download a file from S3 to the given path.
- runway.s3_utils.download_and_extract_to_mkdtemp(bucket: str, key: str, session: Session | None = None) str [source]¶
Download zip archive and extract it to temporary directory.
- runway.s3_utils.ensure_bucket_exists(bucket_name: str, region: str = 'us-east-1', session: Session | None = None) None [source]¶
Ensure S3 bucket exists.
- runway.s3_utils.get_matching_s3_keys(bucket: str, prefix: str = '', suffix: str = '', session: Session | None = None) Iterator[str] [source]¶
Generate the keys in an S3 bucket.
- Parameters:
bucket – Name of the S3 bucket.
prefix – Only fetch keys that start with this prefix (optional).
suffix – Only fetch keys that end with this suffix (optional).
session – Boto3/botocore session.
- runway.s3_utils.get_matching_s3_objects(bucket: str, prefix: Sequence[str] = '', suffix: str = '', session: boto3.Session | None = None) Iterator[ObjectTypeDef] [source]¶
Generate objects in an S3 bucket.
- Parameters:
bucket – Name of the S3 bucket.
prefix – Only fetch objects whose key starts with this prefix (optional).
suffix – Only fetch objects whose keys end with this suffix (optional).
session – Boto3/botocore session.
- runway.s3_utils.purge_and_delete_bucket(bucket_name: str, region: str = 'us-east-1', session: Session | None = None) None [source]¶
Delete all objects and versions in bucket, then delete bucket.