Periodic workflows#41
Draft
daviddavis wants to merge 1 commit into
Draft
Conversation
daviddavis
force-pushed
the
periodic-workflows
branch
from
July 17, 2026 12:51
c4e7164 to
88ef818
Compare
Added support for periodic workflows. A `Workflow` can now be given a `dispatch_interval`, in which case it re-runs on that recurring schedule instead of running just once at `start_time`. fixes pulp#20 Assisted-by: GitHub Copilot (Claude Opus 4.8)
daviddavis
force-pushed
the
periodic-workflows
branch
from
July 17, 2026 13:16
88ef818 to
142fe8b
Compare
daviddavis
marked this pull request as ready for review
July 17, 2026 13:28
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces periodic workflow execution by splitting workflow definition/schedule (Workflow) from workflow execution state (WorkflowRun), allowing a workflow to create recurring runs when dispatch_interval is set.
Changes:
- Added
WorkflowRunmodel + API endpoint and moved execution state (state, timestamps,error,current_task,task_group) fromWorkflowontoWorkflowRun. - Implemented periodic scheduling via
dispatch_intervalby schedulingstart_workflow_run, which creates a run and dispatches execution. - Updated cancellation semantics (stop workflow vs cancel run) and adjusted callback execution/environment to be run-aware; expanded unit + functional coverage.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pulp_workflow/app/models.py | Introduces WorkflowRun and moves execution-state semantics off Workflow. |
| pulp_workflow/app/serializers.py | Adds dispatch_interval to workflows and introduces WorkflowRunSerializer; schedules start_workflow_run. |
| pulp_workflow/app/tasks.py | Adds start_workflow_run; updates execution/callback dispatch to be run-based. |
| pulp_workflow/app/viewsets.py | Adds WorkflowRunViewSet; changes workflow PATCH to “stop schedule + cancel in-flight runs”. |
| pulp_workflow/app/signals.py | Updates TaskGroup cancel propagation to operate on WorkflowRun. |
| pulp_workflow/app/migrations/0005_workflowrun.py | Schema + data migration to add runs, remove old workflow execution fields, and rewrite schedules. |
| pulp_workflow/pytest_plugin.py | Updates fixtures/helpers to monitor runs instead of workflows. |
| pulp_workflow/tests/unit/test_viewsets.py | Adds unit coverage for run permissions/access policy behavior. |
| pulp_workflow/tests/unit/test_tasks.py | Updates unit tests for run-based task execution and start_workflow_run. |
| pulp_workflow/tests/unit/test_models.py | Adjusts callback env tests to use a run wrapper (run state + workflow metadata). |
| pulp_workflow/tests/functional/api/test_execute_workflow.py | Refactors functional assertions to target runs + TaskGroups rather than workflow state. |
| pulp_workflow/tests/functional/api/test_crud_workflows.py | Updates CRUD expectations and stop semantics to be run-based. |
| pulp_workflow/tests/functional/api/test_workflow_callbacks.py | Updates callback functional tests and adds cancellation callback coverage. |
| pulp_workflow/tests/functional/api/test_periodic_workflow.py | Adds functional coverage for periodic run creation and non-overlap behavior. |
| docs/design.md | Updates design documentation to describe definition vs run split and scheduling/cancel flows. |
| CHANGES/20.feature | Changelog entry for periodic workflows + new WorkflowRun resource. |
| CHANGES/20.removal | Changelog entry for removed fields from Workflow / WorkflowTask. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
158
to
+161
| workflow = self.get_object() | ||
| fired_callbacks = False | ||
| # Stop future runs by removing the schedule. | ||
| TaskSchedule.objects.filter(name=f"pulp_workflow.workflow:{workflow.pk}").delete() | ||
|
|
Comment on lines
+32
to
+35
| for run in runs: | ||
| run.state = TASK_STATES.CANCELED | ||
| run.finished_at = timezone.now() | ||
| run.save(update_fields=["state", "finished_at", "pulp_last_updated"]) |
Comment on lines
+31
to
+35
| `start_workflow_run` is deliberately tiny: it creates a `WorkflowRun` and its | ||
| `TaskGroup`, then dispatches the first `execute_workflow` step and returns. | ||
| Because it completes almost immediately, the scheduler's | ||
| "don't dispatch while the last task is still running" guard does not serialize | ||
| runs — overlapping runs of a periodic workflow are allowed by design. |
Comment on lines
+106
to
+110
| Each time a workflow's schedule fires, a ``WorkflowRun`` is created to track that | ||
| execution's state independently of the workflow definition and of any other run. | ||
| This lets a periodic workflow keep a full history of its runs, and lets concurrent | ||
| (overlapping) runs of the same workflow coexist. | ||
|
|
Comment on lines
+9
to
+12
| # Move per-execution state onto WorkflowRun and repoint each workflow's schedule from | ||
| # execute_workflow at start_workflow_run. start_workflow_run reuses the schedule's existing | ||
| # workflow_pk kwarg, so rewriting only task_name revives pending ("waiting") schedules. | ||
| # Prior run history (completed/failed/in-flight) is dropped and not back-filled as WorkflowRun rows. |
daviddavis
marked this pull request as draft
July 17, 2026 15:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added support for periodic workflows. A
Workflowcan now be given adispatch_interval, in which case it re-runs on that recurring schedule instead of running just once atstart_time.fixes #20
Assisted-by: GitHub Copilot (Claude Opus 4.8)
📜 Checklist
See: Pull Request Walkthrough