No project description provided
Project description
mountaineer-cloud
Shared cloud primitives for Python webservices, in particular ones built off of Mountaineer or FastAPI.
Most webapps themselves are cloud-agnostic and can be distributed within any Linux environment. This works pretty well when your whole application is stateless and just talks to a database, but falls down once you actually start needing infrastructure that spawns across your whole cluster. This package exists for the places where that abstraction breaks down and you still need a clean way to work with a real supplier:
- Object storage
- Email delivery
Installation
Install the package as usual. If you want additional dependencies to mock (some) providers locally, also install the mocks extra:
uv add "mountaineer-cloud"
uv add --dev "mountaineer-cloud[mocks]"
Storage Primitive
The core convention for our storage primitives is:
- A provider package establishes how to connect to the real supplier (S3, R2, etc).
- That provider exposes an authenticated
*Coreobject. - A primitive accepts that core object and uses it to perform work.
For storage, that means your field annotation carries the provider core type:
from fastapi import Depends
from iceaxe import Field, TableBase
from mountaineer_cloud import CloudMixin
from mountaineer_cloud.primitives import CloudFile, CloudFileField
from mountaineer_cloud.providers.aws import AWSCore, AWSDependencies
class Asset(CloudMixin, TableBase):
id: int = Field(primary_key=True)
file_url: CloudFile[AWSCore] | None = CloudFileField(
bucket="my-bucket",
prefix="assets",
)
async def upload_asset(
asset: Asset,
aws: AWSCore = Depends(AWSDependencies.get_aws_core),
) -> bytes:
await asset.file_url.put_content(aws, b"hello world")
contents = await asset.file_url.get_content(aws)
return contents
async def get_asset_contents(
asset: Asset,
aws: AWSCore = Depends(AWSDependencies.get_aws_core),
) -> bytes:
return await asset.file_url.get_content(aws)
If you later move that same model or endpoint to another provider, the primitive API stays the same. Thanks to the magic of typehinting, we'll proactively flag errors if you're trying to use a backend provider that doesn't support the functionality you expect. The main thing that changes is the core type:
CloudFile[AWSCore]CloudFile[CloudflareCore]CloudFile[DigitalOceanCore]
CloudFile has support for writing and reading in one fell-swoop, in addition to streaming reads that are more efficient for large files stored remotely.
Email Primitive
Email follows the same convention, except the primitive is a regular embedded Pydantic model instead of a string-backed pointer:
from fastapi import Depends
from iceaxe import Field, TableBase
from mountaineer_cloud import CloudMixin
from mountaineer_cloud.primitives import (
CloudEmailField,
EmailBody,
EmailMessage,
EmailRecipient,
)
from mountaineer_cloud.providers.resend import ResendCore, ResendDependencies
class Notification(CloudMixin, TableBase):
id: int = Field(primary_key=True)
email: EmailMessage[ResendCore] | None = CloudEmailField()
async def send_notification(
notification: Notification,
resend: ResendCore = Depends(ResendDependencies.get_resend_core),
):
notification.email = EmailMessage[ResendCore](
sender=EmailRecipient(
email="noreply@example.com",
display_name="Example App",
),
recipient=EmailRecipient(email="user@example.com"),
subject="Welcome",
body=EmailBody(
text="Welcome to Example App",
html="<p>Welcome to Example App</p>",
),
)
return await notification.email.send(resend)
Providers
Each provider module establishes the concrete connection details for an underlying supplier.
Every provider package follows the same pattern:
*Config: the settings model you inherit into your downstream app config*Core: the authenticated runtime object that combines provider config with an authenticated session*Dependencies: dependency-injected helpers likeget_*_core, useful when using the DI syntax of FastAPI and Mountaineer
This is the center of the convention.
Your endpoint should depend on the provider core, not on a raw client or session. Then your primitive should accept that core and perform the actual work. This keeps supplier-specific connection logic inside the provider package and keeps the primitive surface stable.
| Provider | Storage | Config / Core / Dependencies | |
|---|---|---|---|
| AWS | Yes, via S3 | Yes, via SES | AWSConfig, AWSCore, AWSDependencies |
| Cloudflare | Yes, via R2 | No | CloudflareConfig, CloudflareCore, CloudflareDependencies |
| DigitalOcean | Yes, via Spaces | No | DigitalOceanConfig, DigitalOceanCore, DigitalOceanDependencies |
| Resend | No | Yes | ResendConfig, ResendCore, ResendDependencies |
Environment variables are intentionally omitted here because each provider's settings can evolve over time. The source of truth is the corresponding *Config model in the provider package.
The usage pattern stays the same across providers:
from fastapi import Depends
from mountaineer_cloud.providers.aws import AWSCore, AWSDependencies
async def endpoint(
aws: AWSCore = Depends(AWSDependencies.get_aws_core),
) -> None:
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mountaineer_cloud-0.1.1.tar.gz.
File metadata
- Download URL: mountaineer_cloud-0.1.1.tar.gz
- Upload date:
- Size: 968.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9f49319589c6c1c642568bdfe8ed04124508faecb8805e39442cf626f305691
|
|
| MD5 |
12bede9b1db7915881ec4ca2afcdbd80
|
|
| BLAKE2b-256 |
0c76b00d7d52ac7d5c22a1c10f9f7d1831c150717d754d609696b979178146b7
|
Provenance
The following attestation bundles were made for mountaineer_cloud-0.1.1.tar.gz:
Publisher:
test.yml on piercefreeman/mountaineer-cloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mountaineer_cloud-0.1.1.tar.gz -
Subject digest:
c9f49319589c6c1c642568bdfe8ed04124508faecb8805e39442cf626f305691 - Sigstore transparency entry: 1189520508
- Sigstore integration time:
-
Permalink:
piercefreeman/mountaineer-cloud@597bb59298783b104cda9c7c8c13398c159cb572 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/piercefreeman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@597bb59298783b104cda9c7c8c13398c159cb572 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mountaineer_cloud-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mountaineer_cloud-0.1.1-py3-none-any.whl
- Upload date:
- Size: 44.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
817fbd625e3f3d0445515f81ac2061ed6b522d294ea49653e18a00eca148fa00
|
|
| MD5 |
f492551938d2f932cb25c4a2ee43d959
|
|
| BLAKE2b-256 |
d7b94e7f013cdea3aa11b1a036b572d85819118669c84203276eac5abc4a85ed
|
Provenance
The following attestation bundles were made for mountaineer_cloud-0.1.1-py3-none-any.whl:
Publisher:
test.yml on piercefreeman/mountaineer-cloud
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mountaineer_cloud-0.1.1-py3-none-any.whl -
Subject digest:
817fbd625e3f3d0445515f81ac2061ed6b522d294ea49653e18a00eca148fa00 - Sigstore transparency entry: 1189520512
- Sigstore integration time:
-
Permalink:
piercefreeman/mountaineer-cloud@597bb59298783b104cda9c7c8c13398c159cb572 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/piercefreeman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@597bb59298783b104cda9c7c8c13398c159cb572 -
Trigger Event:
push
-
Statement type: