A unified Python library for interacting with cloud object storage services (AWS S3, Azure Blob Storage, Google Cloud Storage) with support for both synchronous and asynchronous operations.
- Multi-cloud support: AWS S3, Azure Blob Storage, Google Cloud Storage
- Dual mode operation: Synchronous and asynchronous APIs
- Type-safe: Full type hints and mypy support
- Factory pattern: Easy instantiation based on configuration
- Dockerized development: Complete containerized development environment
- Python 3.11+
- Docker and Docker Compose
- Poetry (for dependency management)
- Clone the repository:
git clone <repository-url>
cd deps-object-storage- Install dependencies and setup environment:
make install
make prereq- Build the Docker container:
make buildThe library uses environment variables for configuration. Create a .env file with the following variables:
# Object Storage Configuration
OBJECT_STORAGE_TYPE=aws # Options: aws, azure, gcp
OBJECT_STORAGE_MODE=async # Options: sync, async
# Cloud-specific credentials (set based on your chosen provider)
# AWS
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_DEFAULT_REGION=us-east-1
# Azure
AZURE_STORAGE_CONNECTION_STRING=your_connection_string
# Google Cloud
GOOGLE_APPLICATION_CREDENTIALS=path/to/service-account.jsonfrom deps_object_storage import make_object_storage
# Create object storage instance based on environment configuration
storage = make_object_storage()
# Upload a file
content = b"Hello, World!"
path = "example/file.txt"
uploaded_path = storage.upload(path, content, replace_if_exists=True)
# Download a file
downloaded_content = storage.download(path)
# Delete a file
storage.delete(path)import asyncio
from deps_object_storage import make_object_storage
async def main():
storage = make_object_storage()
if hasattr(storage, 'upload'): # Sync storage
path = storage.upload("async_example.txt", b"Async content", True)
else: # Async storage
path = await storage.upload("async_example.txt", b"Async content", True)
content = await storage.download(path)
await storage.delete(path)
asyncio.run(main())class ObjectStorage(Protocol):
def upload(self, path: str, content: bytes, replace_if_exists: bool) -> str:
"""Upload content to the specified path."""
...
def download(self, path: str) -> bytes:
"""Download content from the specified path."""
...
def delete(self, path: str) -> None:
"""Delete the file at the specified path."""
...class AsyncObjectStorage(Protocol):
async def upload(self, path: str, content: bytes, replace_if_exists: bool) -> str:
"""Upload content to the specified path asynchronously."""
...
async def download(self, path: str) -> bytes:
"""Download content from the specified path asynchronously."""
...
async def delete(self, path: str) -> None:
"""Delete the file at the specified path asynchronously."""
...make install- Copy environment variables from.env.examplemake prereq- Create Docker network and ensure.envexistsmake build- Build Docker containermake format- Format code using black and isortmake format-check- Check code formatting without making changesmake lint- Run flake8 lintermake mypy-check- Run type checking with mypymake ci- Run all CI checks (format, lint, type check)make clean- Clean Python cache files
- Start development environment:
make build- Format code:
make format- Run code quality checks:
make cideps_object_storage/
├── __init__.py # Main package exports
├── object_storage.py # Synchronous storage protocol
├── async_object_storage.py # Asynchronous storage protocol
├── object_storage_factory.py # Factory for creating storage instances
├── settings.py # Configuration management
├── aws/ # AWS S3 implementation
├── azure/ # Azure Blob Storage implementation
├── gcp/ # Google Cloud Storage implementation
└── file_storage/ # DEPS File Storage implementation
pydantic-settings- Configuration managementboto3- AWS SDK for Pythonazure-storage-blob- Azure Blob Storage clientgoogle-cloud-storage- Google Cloud Storage clientgoogle-cloud-core- Google Cloud Core libraryasyncer- Async utilitiesaiohttp- Async HTTP
mypy- Type checkingflake8- Lintingisort- Import sortingblack- Code formatting
MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Run
make cito ensure code quality - Submit a pull request
Valentin