You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2025/10/21 17:47:43 UTC
(airflow) 20/20: Restore timtable active_runs_limit check (#56922)
This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
commit f9cb37b0effe444af961d54ecbde051cec3003d0
Author: Tzu-ping Chung <ur...@gmail.com>
AuthorDate: Tue Oct 21 16:32:32 2025 +0800
Restore timtable active_runs_limit check (#56922)
(cherry picked from commit d16a8207b713bdddd822f1bf6ff04a163a361d34)
---
task-sdk/src/airflow/sdk/definitions/dag.py | 7 +++++++
task-sdk/tests/task_sdk/definitions/test_dag.py | 15 +++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/task-sdk/src/airflow/sdk/definitions/dag.py b/task-sdk/src/airflow/sdk/definitions/dag.py
index 860cbd2110e..d5ae8353bd9 100644
--- a/task-sdk/src/airflow/sdk/definitions/dag.py
+++ b/task-sdk/src/airflow/sdk/definitions/dag.py
@@ -533,6 +533,13 @@ class DAG:
RemovedInAirflow4Warning,
stacklevel=2,
)
+ if (
+ active_runs_limit := self.timetable.active_runs_limit
+ ) is not None and active_runs_limit < self.max_active_runs:
+ raise ValueError(
+ f"Invalid max_active_runs: {type(self.timetable)} "
+ f"requires max_active_runs <= {active_runs_limit}"
+ )
@params.validator
def _validate_params(self, _, params: ParamsDict):
diff --git a/task-sdk/tests/task_sdk/definitions/test_dag.py b/task-sdk/tests/task_sdk/definitions/test_dag.py
index ed8db6b0aac..10f745f9b91 100644
--- a/task-sdk/tests/task_sdk/definitions/test_dag.py
+++ b/task-sdk/tests/task_sdk/definitions/test_dag.py
@@ -466,6 +466,21 @@ def test_create_dag_while_active_context():
# No asserts needed, it just needs to not fail
+@pytest.mark.parametrize("max_active_runs", [0, 1])
+def test_continuous_schedule_interval_limits_max_active_runs(max_active_runs):
+ from airflow.timetables.simple import ContinuousTimetable
+
+ dag = DAG(dag_id="continuous", schedule="@continuous", max_active_runs=max_active_runs)
+ assert isinstance(dag.timetable, ContinuousTimetable)
+ assert dag.max_active_runs == max_active_runs
+
+
+def test_continuous_schedule_interval_limits_max_active_runs_error():
+ with pytest.raises(ValueError) as ctx:
+ DAG(dag_id="continuous", schedule="@continuous", max_active_runs=2)
+ assert str(ctx.value) == "Invalid max_active_runs: ContinuousTimetable requires max_active_runs <= 1"
+
+
class TestDagDecorator:
DEFAULT_ARGS = {
"owner": "test",