Skip to main content

ahi-aws

Thin, typed boto3 helpers for AHI. Today: AWS auth (one session, checked once, with clear errors), running SQL on Redshift (Data API) and Athena, with async query handling, and moving files and folders to and from S3.

from ahi.aws.auth import aws_session, check_identity

session = aws_session()  # AWS_PROFILE / default profile / attached role
identity = check_identity(session)  # raises an AuthError saying what to run
print(identity.arn, identity.method)  # e.g. "sso", "iam-role", "container-role"
from ahi.aws.redshift import RedshiftDataClient
from ahi.aws.athena import AthenaClient

rs = RedshiftDataClient(workgroup_name="analytics", database="dev")
rows = rs.run_query(
    "select count(*) from events where day = :day",
    parameters={"day": "2026-06-26"},
)
print(rows.scalar())

ath = AthenaClient(workgroup="primary", database="analytics")
for row in ath.run_query("select name from users where id = ?", parameters=[42]):
    print(row["name"])
from ahi.aws.auth import aws_session
from ahi.aws.s3 import S3Storage

session = aws_session()
storage = S3Storage("s3://my-bucket/some/prefix", client=session.client("s3"))

uploaded = storage.upload_dir("runs/run-01", prefix="run-01")  # list[S3Object]
storage.download_dir("run-01", "local/run-01")

Design notes

  • Never logs in for you. No browser, no AWS CLI. Run aws sso login beforehand (local SSO), or run where an AWS role is attached (EC2 instance role, ECS task role); missing or expired credentials raise AuthError with the command to run. No default region: set AWS_REGION or the profile's region.
  • Parameterized queries by default. Pass values via parameters (named :name for Redshift, positional ? for Athena) — never format them in.
  • One synchronous call. run_query submits, polls with backoff (see ahi.core.poll_until), and pages the full result set, returning a QueryResult you can iterate, len(), or call .scalar() on.
  • Typed results from Redshift; strings from Athena (Athena returns all values as strings — we preserve that rather than guessing).
  • Failures raise QueryFailedError; timeouts raise PollTimeoutError.
  • S3 transfers return S3Object records (bucket, key, local path, size); failures raise UploadFailedError / DownloadFailedError.

Install the optional types extra (ahi-aws[types]) for boto3-stubs during development.

Part of ahi-python-packages.

Metadata

Release files for ahi-aws 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ahi-aws 0.4.0
File Size Uploaded Provenance Actions
ahi_aws-0.4.0.tar.gz 22.8 kB Without provenance Details for ahi_aws-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ahi-aws 0.4.0
File Interpreter ABI Platform Actions
ahi_aws-0.4.0-py3-none-any.whl Python 3 none any Details for ahi_aws-0.4.0-py3-none-any.whl

Total release size: 40.1 kB

Release files / ahi_aws-0.4.0.tar.gz

Download URL ahi_aws-0.4.0.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6d6de162f977adb690e0fb73ddc0f27b73972aa65ace17379767ec794ea29c86
BLAKE2b-256 checksum
How to use checksums
a47624199f6128d0d0c6092fa9472928171a64fc3c7fd13eb4e3156cae85dc4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / ahi_aws-0.4.0-py3-none-any.whl

Download URL ahi_aws-0.4.0-py3-none-any.whl
Size 17.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4231690f59a2abfaf9037a08942b097c48f8ebe64647d5a0c970280557c35f3e
BLAKE2b-256 checksum
How to use checksums
fb1f661fd96323d394b5fe2a708e93ef8b89d37632d5fe4e4518cb0d1b75bbf6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for ahi-aws 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page