This is a Python library for interacting with the Athena API (Resolver Unknown CSAM Detection).
The Athena client supports two authentication methods:
from athena_client.client.channel import create_channel
# Use a pre-existing authentication token
channel = create_channel(host="your-host", auth_token="your-token")The credential helper automatically handles OAuth token acquisition and refresh:
import asyncio
from athena_client.client.channel import CredentialHelper, create_channel_with_credentials
async def main():
# Create credential helper with OAuth settings
credential_helper = CredentialHelper(
client_id="your-oauth-client-id",
client_secret="your-oauth-client-secret",
auth_url="https://crispthinking.auth0.com/oauth/token", # Optional, this is default
audience="crisp-athena-dev" # Optional, this is default
)
# Create channel with automatic OAuth handling
channel = await create_channel_with_credentials(
host="your-host",
credential_helper=credential_helper
)
asyncio.run(main())For the OAuth example to work, set these environment variables:
export OAUTH_CLIENT_ID="your-client-id"
export OAUTH_CLIENT_SECRET="your-client-secret"
export ATHENA_HOST="your-athena-host"- Automatic token refresh: Tokens are automatically refreshed when they expire
- Thread-safe: Multiple concurrent requests will safely share cached tokens
- Error handling: Comprehensive error handling for OAuth failures
- Configurable: Custom OAuth endpoints and audiences supported
See examples/oauth_example.py for a complete working example.
examples/example.py- Basic classification example with static tokenexamples/oauth_example.py- OAuth authentication with credential helperexamples/create_image.py- Image generation utilities
Make pipeline style invocation of the async interators such that we can
async read file -> async transform -> async classify -> async results
Add additional pipeline transformers for:
- Image format conversion
- Metadata extraction
- Error recovery and retry
This package uses uv to manage its packages.
To install dependencies, run:
uv sync --devTo build the package, run:
uv buildTo run the tests, run:
pytestTo lint and format the code, run:
ruff check
ruff formatThere are pre-commit hooks that will lint, format, and type check the code. Install them with:
pre-commit installTo re-compile the protobuf files, run from the repository's root directory:
bash scripts/compile_proto.sh