Skip to main content

Reliability primitives for Python applications.

Project description

RelPrim

Reliability primitives for external operations in Python.

RelPrim is a production resilience SDK that helps developers build reliable integrations with AI providers, APIs and external services.

Status

🚧 Early development.

RelPrim is currently in active development and APIs may change before the first stable release.

Installation

pip install relprim

Quickstart

import asyncio

from relprim import (
    RetryPolicy,
    TimeoutPolicy,
    async_operation,
    fallback_chain,
)


class TemporaryProviderError(Exception):
    pass


async def call_primary_provider(prompt: str) -> str:
    # Replace this with an OpenAI, Gemini, HTTP, payment or any other external call.
    raise TemporaryProviderError("primary provider temporarily unavailable")


async def call_fallback_provider(prompt: str) -> str:
    # Replace this with a secondary provider, backup API or local implementation.
    return f"Fallback response for: {prompt}"


async def main() -> None:
    result = await (
        async_operation("generate_response", call_primary_provider)
        .with_retry(
            RetryPolicy(
                max_attempts=3,
                retry_on=(TemporaryProviderError,),
            )
        )
        .with_timeout(TimeoutPolicy(seconds=10))
        .with_fallbacks(
            fallback_chain(
                ("fallback_provider", call_fallback_provider),
            )
        )
        .run("Write a short product summary")
    )

    print(result.value)
    print(result.report.to_dict())


asyncio.run(main())

What RelPrim provides

RelPrim focuses on reliability primitives for operations that cross process, network or provider boundaries.

Current primitives:

  • Retry policies
  • Exponential backoff with jitter
  • Async timeout enforcement
  • Async fallback chains
  • Async resilient operation API
  • Structured execution reports
  • Operation results
  • Typed execution errors

Planned primitives:

  • Circuit breakers
  • Validation
  • Idempotency
  • Rate limit handling
  • Structured events
  • SQLite event store
  • OpenTelemetry exporter

What RelPrim is not

RelPrim is not a workflow engine, agent framework, task queue, chatbot framework or AI provider wrapper.

It is a reliability SDK for external operations.

License

Apache License 2.0

Project details


Download files

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

Source Distribution

relprim-0.3.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

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

relprim-0.3.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file relprim-0.3.0.tar.gz.

File metadata

  • Download URL: relprim-0.3.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for relprim-0.3.0.tar.gz
Algorithm Hash digest
SHA256 19bfa399e2a439bb2e0cfe7233bec26224ba63342383b5bc0ecf9f83d861f3b2
MD5 4da9608aa7085f4f64bcfe2558a081aa
BLAKE2b-256 0932b222f8c4433e017e7681236813107cf9e6cad2759a00e7875ea465bc691b

See more details on using hashes here.

File details

Details for the file relprim-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: relprim-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for relprim-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4aa6ecf6d50a9cba855920248e774382e945174c6588be775e4664b065c7818
MD5 0ea8a153f28f5b5bdafef097f3f791ff
BLAKE2b-256 4bbfd2022e2c7fd1daaab885ea1c3555e6d3340370b28fcc9c408378c2ebe985

See more details on using hashes here.

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