File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
src/airflow/sdk/definitions
tests/task_sdk/definitions Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -533,6 +533,13 @@ def __attrs_post_init__(self):
533533 RemovedInAirflow4Warning ,
534534 stacklevel = 2 ,
535535 )
536+ if (
537+ active_runs_limit := self .timetable .active_runs_limit
538+ ) is not None and active_runs_limit < self .max_active_runs :
539+ raise ValueError (
540+ f"Invalid max_active_runs: { type (self .timetable )} "
541+ f"requires max_active_runs <= { active_runs_limit } "
542+ )
536543
537544 @params .validator
538545 def _validate_params (self , _ , params : ParamsDict ):
Original file line number Diff line number Diff line change @@ -470,6 +470,21 @@ def test_create_dag_while_active_context():
470470 # No asserts needed, it just needs to not fail
471471
472472
473+ @pytest .mark .parametrize ("max_active_runs" , [0 , 1 ])
474+ def test_continuous_schedule_interval_limits_max_active_runs (max_active_runs ):
475+ from airflow .timetables .simple import ContinuousTimetable
476+
477+ dag = DAG (dag_id = "continuous" , schedule = "@continuous" , max_active_runs = max_active_runs )
478+ assert isinstance (dag .timetable , ContinuousTimetable )
479+ assert dag .max_active_runs == max_active_runs
480+
481+
482+ def test_continuous_schedule_interval_limits_max_active_runs_error ():
483+ with pytest .raises (ValueError ) as ctx :
484+ DAG (dag_id = "continuous" , schedule = "@continuous" , max_active_runs = 2 )
485+ assert str (ctx .value ) == "Invalid max_active_runs: ContinuousTimetable requires max_active_runs <= 1"
486+
487+
473488class TestDagDecorator :
474489 DEFAULT_ARGS = {
475490 "owner" : "test" ,
You can’t perform that action at this time.
0 commit comments