ensure_from_s3

ensure_from_s3(key: str, *subkeys: str, s3_bucket: str, s3_key: str | Sequence[str], name: str | None = None, force: bool = False, **kwargs: Any) Path[source]

Ensure a file is downloaded.

Parameters:
  • key – The name of the module. No funny characters. The envvar <key>_HOME where key is uppercased is checked first before using the default home directory.

  • subkeys – A sequence of additional strings to join. If none are given, returns the directory for this module.

  • s3_bucket – The S3 bucket name

  • s3_key – The S3 key name

  • name – Overrides the name of the file at the end of the S3 key, if given.

  • force – Should the download be done again, even if the path already exists? Defaults to false.

  • kwargs – Remaining kwargs to forwrad to Module.ensure_from_s3.

Returns:

The path of the file that has been downloaded (or already exists)

Example downloading ProtMapper 0.0.21:

import pystow

version = "0.0.21"
pystow.ensure_from_s3(
    "test",
    version,
    s3_bucket="bigmech",
    s3_key=f"protmapper/{version}/refseq_uniprot.csv",
)