Skip to content

Latest commit

 

History

History

python

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Python example

Create a Render Sandbox and mount a private S3 bucket, a private R2 bucket, or both. This project uses the Render Python SDK. See the shared guide for bucket permissions, FUSE requirements, and operational limits.

Setup

Use Python 3.11 or later and uv. From the repository root:

cd python
cp ../.env.example .env
uv sync --locked

Edit .env. Set RENDER_API_KEY, RENDER_WORKSPACE_ID, and the selected provider's settings. Follow the S3 setup or R2 setup. Git ignores .env.

Run

# Mount both buckets as read-only and list up to 10 entries from each.
uv run --env-file .env python example.py both

# Mount one bucket with only that provider's settings.
uv run --env-file .env python example.py s3
uv run --env-file .env python example.py r2

# Run a command while both buckets are mounted.
uv run --env-file .env python example.py both \
  --command 'find /mnt/s3 /mnt/r2 -maxdepth 1 -type f'

# Write an object, remount, read it, and delete it from each bucket.
uv run --env-file .env python example.py both --write-demo

The write check needs write and delete permission. See the write check guide before you use it. Each run terminates its sandbox in finally and sets a 15-minute maximum lifetime.

Files

Validate

uv run ruff check .
uv run ruff format --check .
uv run python -m unittest discover -s tests -v