download_from_s3

download_from_s3(s3_bucket: str, s3_key: str, path: str | Path, client: None | botocore.client.BaseClient = None, client_kwargs: Mapping[str, Any] | None = None, download_file_kwargs: Mapping[str, Any] | None = None, force: bool = True, clean_on_failure: bool = True) None[source]

Download a file from S3.

Parameters:
  • s3_bucket – The key inside the S3 bucket name

  • s3_key – The key inside the S3 bucket

  • path – The place to write the file

  • client – A botocore client. If none given, one will be created automatically

  • client_kwargs – Keyword arguments to be passed to the client on instantiation.

  • download_file_kwargs – Keyword arguments to be passed to boto3.s3.transfer.S3Transfer.download_file()

  • force – If false and the file already exists, will not re-download.

  • clean_on_failure – If true, will delete the file on any exception raised during download

Raises:
  • Exception – Thrown if an error besides a keyboard interrupt is thrown during download

  • KeyboardInterrupt – If a keyboard interrupt is thrown during download

  • UnexpectedDirectory – If a directory is given for the path argument