Skip to main content

State persistance using Redis as backend

Project description

pydantic-graph-redis-persistance

PyPI - Version

Installation

The package is available on PyPi and can be install via pip or any other package manager:

pip install pydantic-graph-redis-persistance

Usage

The responsability of creating a proper asynchronous Redis client is yours, then you can simply create a state persistance instance for your graph run:

from pydantic_graph.persistance.redis import RedisStatePersistance
from redis.asyncio import Redis

redis = Redis(...)
run_id = "my_unique_run_id"
persistance = RedisStatePersistance(redis, run_id)

# You can now use your persistance through any graph run :).

Locking

To provide a quick and simple implementation, the current version use a deprecated Redis locking mecanism through SETNX operation. If you want you can implement your own locking mecanism (for instance redlock) or add a custom timeout to the lock you can provide you own AbstractRedisStateLock instance:

from pydantic_graph.persistance.redis import NXRedisStateLock
from pydantic_graph.persistance.redis import RedisStatePersistance

redis = Redis(...)
lock = NXRedisStateLock(
    lock_id="my_custom_lock_id",
    redis=redis,
    timeout=10000.0,
)
run_id = "my_unique_run_id"
persistance = RedisStatePersistance(redis, run_id, redis_state_lock=lock)

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

pydantic_graph_persistance_redis-0.8.1.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file pydantic_graph_persistance_redis-0.8.1.tar.gz.

File metadata

File hashes

Hashes for pydantic_graph_persistance_redis-0.8.1.tar.gz
Algorithm Hash digest
SHA256 4a999f24c498c3980aba23dc93c06dee0fe34b41bad4621267845d3a1780fc5f
MD5 40173db44b20ea8b6055be3657f012fa
BLAKE2b-256 fee005d7545c0a87f7de9540191eed698b1a1f1454627ea04e01c64c305242e1

See more details on using hashes here.

File details

Details for the file pydantic_graph_persistance_redis-0.8.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_graph_persistance_redis-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8496868af12e47effe331190618b9dcaf7bb7962a7981e4d2ea1c16df1f9e246
MD5 5b7467ac9168abcd43e16a889d63de19
BLAKE2b-256 73b63428f804f76e385ba9a6c7a7d765d0449291ba014fe9133012f936fca868

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