State persistance using Redis as backend
Project description
pydantic-graph-redis-persistance
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_graph_persistance_redis-0.8.1.tar.gz.
File metadata
- Download URL: pydantic_graph_persistance_redis-0.8.1.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a999f24c498c3980aba23dc93c06dee0fe34b41bad4621267845d3a1780fc5f
|
|
| MD5 |
40173db44b20ea8b6055be3657f012fa
|
|
| BLAKE2b-256 |
fee005d7545c0a87f7de9540191eed698b1a1f1454627ea04e01c64c305242e1
|
File details
Details for the file pydantic_graph_persistance_redis-0.8.1-py3-none-any.whl.
File metadata
- Download URL: pydantic_graph_persistance_redis-0.8.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8496868af12e47effe331190618b9dcaf7bb7962a7981e4d2ea1c16df1f9e246
|
|
| MD5 |
5b7467ac9168abcd43e16a889d63de19
|
|
| BLAKE2b-256 |
73b63428f804f76e385ba9a6c7a7d765d0449291ba014fe9133012f936fca868
|