Celery¶
Celery is for projects that already run broker-backed worker pools and want selected Wove tasks to enter those workers instead of running in the web or orchestration process.
Use When¶
Your project already has a Celery broker and workers.
Work should leave the submitting process quickly.
You want Wove’s inline dependency graph but Celery’s worker deployment model.
Execution Shape¶
Wove submits the payload with
app.send_task(...).A Celery worker runs the configured task name.
That task calls
wove.integrations.worker.run(payload).The worker posts Wove completion events back to the callback URL embedded in the payload.
Dependency¶
Install dispatch support and Celery in the process that submits work and in the workers that execute it.
pip install "wove[dispatch]" celery
Configure Wove¶
import wove
wove.config(
default_environment="celery",
environments={
"celery": {
"executor": "celery",
"executor_config": {
"broker_url": "redis://redis:6379/0",
"result_backend": "redis://redis:6379/1",
"task_name": "myapp.wove_task",
"queue": "wove",
"callback_token": "shared-secret",
"callback_url": "https://wove-runner.internal/wove/events/shared-secret",
},
}
},
)
You can also pass an existing Celery app as executor_config["app"]. If app is omitted, Wove creates one from broker_url, result_backend, and app_name.
callback_host and callback_port configure the callback server Wove starts in the process running the weave. callback_url is the address Celery workers call after they execute the payload. In container deployments, that usually means Wove binds to a local port and callback_url uses the service name or internal load balancer that reaches that port.
Worker Task¶
from celery import Celery
from wove.integrations.worker import run
app = Celery("myapp", broker="redis://redis:6379/0", backend="redis://redis:6379/1")
@app.task(name="myapp.wove_task")
def wove_task(payload):
return run(payload)
The worker must have Wove installed and must be able to import the application code referenced by the serialized task.
run(payload) executes the transported Wove callable and posts the result or error back to Wove’s callback server. The Celery task’s own return value is not how the inline weave receives the task result.
Options¶
Key |
Effect |
|---|---|
|
Existing Celery app. |
|
Broker URL used when Wove creates the app. |
|
Result backend used when Wove creates the app. |
|
App name used when Wove creates the app. Defaults to |
|
Celery task name to call. Defaults to |
|
Optional Celery queue. |
|
Extra keyword arguments passed to |
|
Passed to |