Async Drive sync via Django tasks (#57) #58

Merged
westfarn merged 1 commits from feature/async-drive-sync-57 into master 2026-08-02 04:06:55 -07:00
Owner

Summary

  • Closes #57
  • Companion FE: chat_web_app#90 / PR #91
  • POST /api/drive/connections/<id>/sync/ enqueues via Django 6 Tasks (drive_tasks.enqueue_drive_sync) and returns 202 with last_sync_status=pending
  • Webhooks + manage.py sync_drive_connections use the same enqueue path (--sync-now for inline/cron)
  • With default ImmediateBackend, sync still runs in-process but on a daemon thread so HTTP returns quickly; swap TASKS later for a durable worker
  • Duplicate syncs while already pending are skipped (unless force=True)

Test plan

  • manage.py test chat_backend.tests.test_drive_tasks chat_backend.tests.test_views_drive chat_backend.tests.test_management_drive_sync
  • Manual: Sync now returns fast; connection flips pending → ok/error
  • Manual: Google Drive API disabled → last_sync_status=error + message in last_sync_error
  • Manual: second Sync while pending does not stack jobs
## Summary - Closes [#57](https://git.aimloperations.com/ai_ml_operations/chat_backend/issues/57) - Companion FE: [chat_web_app#90](https://git.aimloperations.com/ai_ml_operations/chat_web_app/issues/90) / [PR #91](https://git.aimloperations.com/ai_ml_operations/chat_web_app/pulls/91) - `POST /api/drive/connections/<id>/sync/` enqueues via Django 6 Tasks (`drive_tasks.enqueue_drive_sync`) and returns **202** with `last_sync_status=pending` - Webhooks + `manage.py sync_drive_connections` use the same enqueue path (`--sync-now` for inline/cron) - With default `ImmediateBackend`, sync still runs in-process but on a **daemon thread** so HTTP returns quickly; swap `TASKS` later for a durable worker - Duplicate syncs while already `pending` are skipped (unless `force=True`) ## Test plan - [x] `manage.py test chat_backend.tests.test_drive_tasks chat_backend.tests.test_views_drive chat_backend.tests.test_management_drive_sync` - [ ] Manual: Sync now returns fast; connection flips pending → ok/error - [ ] Manual: Google Drive API disabled → `last_sync_status=error` + message in `last_sync_error` - [ ] Manual: second Sync while pending does not stack jobs
westfarn added 1 commit 2026-08-02 04:02:59 -07:00
Enqueue Drive sync as a Django task and return 202 (#57).
CI / test (pull_request) Successful in 10s
Unit Tests / test (pull_request) Successful in 10s
098d781818
Sync now / webhooks / cron share enqueue_drive_sync so HTTP no longer
blocks on Drive list/ingest. ImmediateBackend still runs in-process via
a background thread; status and errors stay on the connection for FE poll.
westfarn merged commit fd12bb972d into master 2026-08-02 04:06:55 -07:00
westfarn deleted branch feature/async-drive-sync-57 2026-08-02 04:06:55 -07:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ai_ml_operations/chat_backend#58