Skip to content

Conversation

@khvn26
Copy link
Member

@khvn26 khvn26 commented Mar 27, 2025

  • Port flagsmith/flagsmith-task-processor
  • Port waitfordb management command
  • Introduce PostgreSQL for tests
  • Bump Poetry from 2.0.1 to 2.1.1

- Port `flagsmith/flagsmith-task-processor`
- Port `waitfordb` management command
- Introduce PostgreSQL for tests
- Bump Poetry from 2.0.1 to 2.1.1
@khvn26 khvn26 requested a review from Copilot March 27, 2025 00:26
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 adds a Task Processor feature and updates related configurations and utilities. Key changes include:

  • New migrations to support task index updates, completion tracking, and recurring tasks.
  • Introduction of a waitfordb management command and health check utilities.
  • Updates to dependency versions, docker-compose settings, and management commands to support the new task processor.

Reviewed Changes

Copilot reviewed 56 out of 57 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/task_processor/migrations/0004_recreate_task_indexes.py Introduces new index operations for tasks.
src/common/core/management/commands/waitfordb.py Adds a command to wait for database readiness and migration application.
src/task_processor/migrations/0005_update_conditional_index_conditions.py Updates conditional index conditions with new migration steps.
src/task_processor/apps.py Registers a health check backend under specific settings.
src/task_processor/admin.py Provides an admin interface for recurring tasks.
src/task_processor/migrations/0003_add_completed_to_task.py Adds a completed field to tasks and updates index together settings.
src/task_processor/migrations/0002_healthcheckmodel.py Adds a model dedicated to task processor health checking.
src/task_processor/health.py Implements health check logic and backend for task processor status.
docker/docker-compose.local.yml Configures local PostgreSQL service for development.
src/task_processor/migrations/0001_initial.py Initial migration for the task processor models.
src/task_processor/migrations/0006_auto_20230221_0802.py Adds recurring task models and unique constraints.
src/task_processor/decorators.py Introduces decorators for task registration and execution.
src/task_processor/managers.py Implements custom managers for task queries.
.github/workflows/python-test.yml Adjusts test workflow steps to use make commands and PostgreSQL service.
src/task_processor/exceptions.py Defines custom exceptions related to task processing.
pyproject.toml Updates dependencies and package inclusion for the task processor.
settings/dev.py Switches development database to PostgreSQL and adds task processor settings.
src/common/core/management/commands/start.py Adds a sub-command for starting the Task Processor alongside the API.
Files not reviewed (1)
  • Makefile: Language not supported

@khvn26 khvn26 force-pushed the feat/task-processor branch from 39507be to a44aad2 Compare March 27, 2025 00:38
@khvn26 khvn26 requested a review from Copilot March 27, 2025 13:17
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 introduces a new task processor by porting features from flagsmith-task-processor and waitfordb, integrating PostgreSQL for tests, and bumping Poetry’s version.

  • Adds migrations to update the Task model and indexes.
  • Introduces a new waitfordb management command for database readiness.
  • Enhances task processor functionality and its integrations (managers, decorators, admin, health checks).

Reviewed Changes

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

Show a summary per file
File Description
src/task_processor/migrations/0004_recreate_task_indexes.py Adds migration to update indexes with PostgreSQL-specific SQL operations.
src/task_processor/migrations/0003_add_completed_to_task.py Adds the "completed" field to the Task model and alters index together configuration.
src/task_processor/migrations/0002_healthcheckmodel.py Creates a HealthCheckModel for processor health checks.
src/task_processor/migrations/0001_initial.py Initial migration for Task and TaskRun models.
src/task_processor/managers.py Implements custom managers for retrieving tasks to process.
src/task_processor/health.py Implements processor health check and registers the health check backend.
src/task_processor/exceptions.py Defines custom exceptions related to task processing.
src/task_processor/decorators.py Provides decorators for registering asynchronous and recurring tasks.
src/task_processor/apps.py Updates Django app configuration to register the health check backend conditionally.
src/task_processor/admin.py Enhances admin interface for recurring tasks, including custom actions and display fields.
src/common/core/utils.py Adds logging to the utility functions.
src/common/core/management/commands/waitfordb.py Introduces a waitfordb command to wait for database connections and applied migrations.
src/common/core/management/commands/start.py Extends the start command to support running the task processor alongside the API.
src/common/core/main.py Refactors environment setup for the CLI entry point through a context manager.
settings/dev.py Updates development settings to use PostgreSQL, configures task processor parameters, etc.
pyproject.toml Updates dependencies (e.g., Django, backoff, drf-yasg, psycopg2) and bumps the Poetry version.
docker/docker-compose.local.yml Provides a local Docker Compose configuration for PostgreSQL.
.github/workflows/python-test.yml Updates GitHub Actions workflow to include a PostgreSQL service for testing.
Files not reviewed (1)
  • Makefile: Language not supported
Comments suppressed due to low confidence (1)

src/task_processor/migrations/0004_recreate_task_indexes.py:26

  • Consider replacing the tuple argument with a keyword argument in the Q object by using models.Q(completed=False) to ensure the query condition works as expected.
                        condition=models.Q(("completed", False)),

khvn26 and others added 5 commits March 27, 2025 16:06
Co-authored-by: Matthew Elwell <matthew.elwell@flagsmith.com>
Co-authored-by: Matthew Elwell <matthew.elwell@flagsmith.com>
@khvn26 khvn26 requested a review from matthewelwell March 27, 2025 17:10
@khvn26 khvn26 merged commit 9e224f1 into main Mar 27, 2025
4 checks passed
This was referenced Jul 29, 2025
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.

3 participants