[dd] added the "skip run if previous run still in progress" checkbox option#5961
[dd] added the "skip run if previous run still in progress" checkbox option#5961dacdao1 wants to merge 2 commits intomage-ai:masterfrom
Conversation
… the frontend and added the previous run api trigger in the backend
There was a problem hiding this comment.
Pull request overview
This PR implements the "Skip run if previous run still in progress" feature for API-triggered pipelines. The checkbox option is now available for all schedule types (API, Event, and Time) in the frontend, and the backend enforces the skip logic for API triggers by canceling new runs when existing runs are still in progress.
Changes:
- Added comprehensive unit tests for API trigger skip logic covering various scenarios (disabled, enabled with running/initial/completed/no runs, multiple concurrent runs)
- Implemented backend logic to check for in-progress pipeline runs (INITIAL or RUNNING status) and cancel new runs with an appropriate message when the skip setting is enabled
- Moved the skip checkbox in the frontend from being TIME-schedule-specific to being available for all schedule types
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| mage_ai/tests/server/api/test_api_triggers.py | New comprehensive test suite covering all scenarios for the skip_if_previous_running feature in API triggers |
| mage_ai/server/api/triggers.py | Added logic to check for in-progress runs and cancel new pipeline runs when skip_if_previous_running is enabled |
| mage_ai/frontend/components/Triggers/Edit/index.tsx | Moved skip_if_previous_running checkbox outside of TIME schedule type conditional to make it available for all schedule types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) | ||
|
|
||
| if pipeline_schedule.get_settings().skip_if_previous_running: | ||
| running_pipeline_run_count = PipelineRun.query.filter( |
There was a problem hiding this comment.
@dacdao1 Can't you just use pipeline_schedule.running_pipeline_run_count instead of building out the query again here? It checks for pipeline runs with the running status (not initial status), but it should keep the "Skip run if previous run still in progress" setting consistent.
Here's the reference to the running_pipeline_run_count property.
Description
#5512 Added the "Skip run if previous run still in progress" option for the frontend of the application, where the checkbox will appear when the user selects API as a trigger run. The backend will also update with the following logic,
If enabled AND running jobs > 0 → Cancel run with message → Return cancelled run info
How Has This Been Tested?
Checklist
cc:
Hi @johnson-mage, I made a frontend update based on the user request within their enhancement. The "skip run if previous run still in progress" now appears for both the API and the Schedule option.
Hi @wangxiaoyou1993, I also made an update to the backend that triggers when the API is called, and the logic checks whether any jobs are currently running. If there are job(s) running, the current trigger request will be canceled.