A library for serializing Pydantic models in Celery tasks
Project description
Celery Pydantic
A library that provides seamless integration between Celery and Pydantic models, allowing you to serialize and deserialize Pydantic models in Celery tasks.
Installation
pip install celery-pydantic
Usage
from celery import Celery
from pydantic import BaseModel
from celery_pydantic import pydantic_celery
# Define your Pydantic model
class User(BaseModel):
name: str
age: int
# Create your Celery app
app = Celery('myapp')
# Configure the app to use Pydantic serialization
pydantic_celery(app)
# Use Pydantic models in your tasks
@app.task
def process_user(user: User):
return user.name
# Call the task with a Pydantic model
user = User(name="John", age=30)
result = process_user.delay(user)
Features
- Automatic serialization and deserialization of Pydantic models in Celery tasks
- Support for nested Pydantic models
- Maintains type safety throughout the task execution
- Compatible with Celery's result backend
Testing
To run the tests locally:
uv sync --all-extrasuv run pytest
Requirements
- Python 3.9+
- Celery 5.0+
- Pydantic 2.0+
License
MIT License
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
celery_pydantic-0.1.0.tar.gz
(4.4 kB
view details)
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 celery_pydantic-0.1.0.tar.gz.
File metadata
- Download URL: celery_pydantic-0.1.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79c542981886919540fcbc5c1f06b2b7cb24e82d3ef49b3e155d678f36fffce9
|
|
| MD5 |
e6001f0926475897be935d74fcddca9e
|
|
| BLAKE2b-256 |
2462691c455c536443d6fdfe1b043bbdb4cbc89a420fb3e5ef42ca12fbeb7f02
|
File details
Details for the file celery_pydantic-0.1.0-py3-none-any.whl.
File metadata
- Download URL: celery_pydantic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b34313807181f9ea504603708fe05cbfa9f66ba639dada337349c9fd506df0b
|
|
| MD5 |
428c7c7689bfe198c729d0572ed6968a
|
|
| BLAKE2b-256 |
f8bd166ea8bc42ed8c88309bd8073652697e2997d18d99a5e4e3f6a2f26b890a
|