E52F [dd] added the "skip run if previous run still in progress" checkbox option by dacdao1 · Pull Request #5961 · mage-ai/mage-ai · GitHub
[go: up one dir, main page]

Skip to content

[dd] added the "skip run if previous run still in progress" checkbox option#5961

Open
dacdao1 wants to merge 2 commits intomage-ai:masterfrom
dacdao1:feature/API-triggers-skip-run-if-previous-option
Open

[dd] added the "skip run if previous run still in progress" checkbox option#5961
dacdao1 wants to merge 2 commits intomage-ai:masterfrom
dacdao1:feature/API-triggers-skip-run-if-previous-option

Conversation

@dacdao1
Copy link
Contributor
@dacdao1 dacdao1 commented Nov 28, 2025

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?

  • Manually tested in local environment.
  1. Ran Docker Compose to start the backend and frontend server.
  2. Check if the checkbox appears in the frontend application
image 4. Run the trigger with the skip run selection option selected 5. Check the database to see if it will skip the current run if there is one running already.
  • Unit Test
  1. Added the test_api_triggers.py unit test file for testing the endpoint.

Checklist

  • The PR is tagged with proper labels (bug, enhancement, feature, documentation)
  • I have performed a self-review of my own code
  • I have added unit tests that prove my fix is effective or that my feature works
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

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.

… the frontend and added the previous run api trigger in the backend
Copy link
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 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(
Copy link
Member

Choose a reason for hiding this comment

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

@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.

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

0