Skip to main content

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', broker='amqp://')

# 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:

  1. uv sync --all-extras
  2. uv run pytest

Requirements

  • Python 3.9+
  • Celery 5.0+
  • Pydantic 2.0+

License

MIT License

Metadata

Release files for celery-pydantic 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for celery-pydantic 1.0.1
File Size Uploaded
celery_pydantic-1.0.1.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for celery-pydantic 1.0.1
File Interpreter ABI Platform
celery_pydantic-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.2 kB

Release files / celery_pydantic-1.0.1.tar.gz

Download URL celery_pydantic-1.0.1.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3b746bdf306a574ea9296441fc32d18e9f35cc6e5f07096ae03e422be2b5a54f
BLAKE2b-256 checksum
How to use checksums
6eaa4d734614a34ceb214f971aa6940d9f7a74f4f1d4026ca2231ed3b5b8ad29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / celery_pydantic-1.0.1-py3-none-any.whl

Download URL celery_pydantic-1.0.1-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ce1c0279fe2ea20055f1aa2323fb7069fdd8883b191710fedc726d38f249086
BLAKE2b-256 checksum
How to use checksums
ed15bea1b41c76f3e9c18fd6ec53f82df2802ce48d8b7f030b4f529d30b7d30b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page