Skip to main content

Atomic-like Agnostic Object Storage Framework, the Pydantic way

Project description

Atomic-like Agnostic Object Storage Framework, the Pydantic way

CI Codacy Coverage Roadmap PyPI versions License: MIT Last Commit Codacy Grade

Documentation: 📖 Docs


FennFlow is a Python s3 framework designed to help you quickly, confidently, and painlessly manipulate files in your object storage implementing SSOT pattern and Saga compensation flow.

Why use FennFlow?

Working with aiobotocore often feels like handling raw bytes and dicts. FennFlow wraps S3 operations into a high-level Unit of Work pattern, providing:

  • Atomic-like multistep operations — if something fails, previous actions are automatically compensated (Saga Pattern).
  • Clean Architecture — treat S3 as proper repositories using mixins (PutRepository, GetRepository, etc.).
  • Pydantic-powered models — work with TextContent, JsonContent, ImageContent and others instead of raw bytes.

Supported Connectors

Connector Description Documentation
AWS S3 (default) s3 compatible object storage via aiobotocore 📖 Docs
In-Memory great for and tests and development 📖 Docs

Supported Backends

FennFlow uses backend as a source of truth for your file storage. No matter what your file storage contains, backend ensures your data is consistent.

Backend Description Documentation
In-Memory great for and tests, development 📖 Docs
SQLAlchemy (default) persistent metadata backend, great for all environments 📖 Docs

Backend Comparison

Raw aiobotocore SQLAlchemy (default)
Consistency 🔴 None
No link between files and metadata
✅ High
Persistent across restarts
Compensation 🔴 None
Orphaned files on failure
✅ High
Automatic within session
Reliability 🔴 Low
Failures leave storage in unknown state
✅ High
Consistent state guaranteed across restarts
Latency ✅ Lowest
Pure S3 network overhead only
🟡 Low/middle
DB overhead
Infrastructure ✅ None ✅ None
SQLite by default
Memory usage ✅ None ✅ Minimal
Metadata persisted to disk, not held in-process

Quick Start

Here's a minimal example of FennFlow:

import asyncio

from fennflow import ConfigDict, UnitOfWork
from fennflow.backends import SqlalchemyBackendConfig
from fennflow.connectors import S3ConnectorConfig
from fennflow.files import BinaryContent, JsonContent, TextContent
from fennflow.repositories import (
    DeleteRepository,
    GetRepository,
    ListRepository,
    PutRepository,
    S3RepoField,
    )


# 1. Define your repository with mixins
class CrudRepository(
    PutRepository,
    DeleteRepository,
    GetRepository,
    ListRepository,
    ):
    pass


# 2. Set up your Unit of Work
class UOW(UnitOfWork):
    my_files = S3RepoField(CrudRepository, bucket_name="my_files")
    config = ConfigDict(
        backend=SqlalchemyBackendConfig(),
        connector=S3ConnectorConfig(),
        )


async def main():
    text_file = TextContent.from_content("Hello, world!")
    json_file = JsonContent.from_content([1, 2, 3])
    binary_file = BinaryContent(data=b"some bytes", media_type="text/plain")

    async with UOW() as uow:
        await uow.my_files.at("folder1").put(
            text_file,
            json_file,
            binary_file,
            )

        paths = await uow.my_files.at("folder1").list()
        print(paths)  # ListResponse[Filepath, ...]

        files = await uow.my_files.get(*paths)
        print(files)  # MediaResponse[TextContent, JsonContent, BinaryContent]


if __name__ == "__main__":
    asyncio.run(main())

(This example is complete, it can be run “as is”, assuming you’ve installed the fennflow package)

Next Steps

To try FennFlow for yourself, clone it and follow the instructions in the examples.

Read the docs to learn more about working with FennFlow.

Read the API Reference to understand FennFlow’s interface.

Learn how to utilize llms with FennFlow.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fennflow-0.2.0.tar.gz (237.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fennflow-0.2.0-py3-none-any.whl (106.6 kB view details)

Uploaded Python 3

File details

Details for the file fennflow-0.2.0.tar.gz.

File metadata

  • Download URL: fennflow-0.2.0.tar.gz
  • Upload date:
  • Size: 237.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for fennflow-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1e774afaa08db9210f67cf774cb385fba9c2b923f5b14c452a3bb936fe850c7e
MD5 18b125262c7d4d10507284c311ee2ba0
BLAKE2b-256 f4cf82055e7be319d7d527abf870b8aec1138b4e8725e6c219de78c561727b22

See more details on using hashes here.

Provenance

The following attestation bundles were made for fennflow-0.2.0.tar.gz:

Publisher: publish.yml on Alex-FIR-IT/FennFlow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fennflow-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: fennflow-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 106.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for fennflow-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d8f6e944e25636a09185afe3af7ceabdb85836a37c8715de29852b57a6a1864
MD5 5fbe1b4857d9b1e53c9abb4241e2fc1a
BLAKE2b-256 641adc72fc27fad741acf168e4359f36d1d8e11289b5de763bb0311550e9fd06

See more details on using hashes here.

Provenance

The following attestation bundles were made for fennflow-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Alex-FIR-IT/FennFlow

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page