Skip to content

feature: centralizes Celery task handling in shared helpers and configures result expiration#70

Merged
JoeGaffney merged 2 commits intomainfrom
2026-01-22-b
Jan 23, 2026
Merged

feature: centralizes Celery task handling in shared helpers and configures result expiration#70
JoeGaffney merged 2 commits intomainfrom
2026-01-22-b

Conversation

@JoeGaffney
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings January 23, 2026 10:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes Celery task handling in shared helpers and configures result expiration, while simplifying the API routers to use the new helpers and common settings.

Changes:

  • Add a result_expires_days setting in both API and worker configs and wire it into the Celery app configuration to control task result TTL.
  • Introduce create_task and get_task_detailed helpers in api/common/task_helpers.py, and refactor the images, videos, texts, and workflows routers to use them instead of direct celery_app access.
  • Improve task introspection by combining queue-position lookup and Flower metadata, and change the behavior for unknown/expired tasks to return a 404 instead of a "task not found" log with 200.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
workers/common/config.py Adds result_expires_days setting for worker-side Celery result expiry.
workers/worker.py Configures worker Celery app to expire results based on settings.result_expires_days.
api/common/config.py Adds API-side result_expires_days setting to keep API and worker Celery configs aligned.
api/worker.py Configures API Celery client to use result_expires_days for result expiry.
api/common/task_helpers.py Refactors task utilities to include a unified create_task, a richer get_task_detailed (with Flower and Redis queue info plus 404 on missing tasks), and a simplified cancel_task.
api/images/router.py Refactors image endpoints to use create_task/get_task_detailed and the new cancel_task signature, while preserving response models and behavior.
api/videos/router.py Same refactor pattern as images router for video task creation, polling, and cancellation.
api/texts/router.py Refactors text endpoints to use the shared helpers, simplifying task creation and polling.
api/workflows/router.py Refactors workflow endpoints to use the shared helpers and maintain signed URL generation for outputs.

@JoeGaffney JoeGaffney changed the title 2026 01 22 b feature: centralizes Celery task handling in shared helpers and configures result expiration Jan 23, 2026
@JoeGaffney JoeGaffney merged commit dd838dc into main Jan 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants