This is an automated email from the ASF dual-hosted git repository.
Lee-W pushed a commit to branch v3-3-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-3-test by this push:
new 6a2ba8fdb82 [v3-3-test] Rename misleading last_automated_run param to
reference_run (#68714) (#68753)
6a2ba8fdb82 is described below
commit 6a2ba8fdb82be8cbdcc9cc97e467675d964471bf
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Jun 19 23:20:38 2026 +0800
[v3-3-test] Rename misleading last_automated_run param to reference_run
(#68714) (#68753)
Co-authored-by: Wei Lee <[email protected]>
---
airflow-core/src/airflow/dag_processing/collection.py | 4 ++--
airflow-core/src/airflow/jobs/scheduler_job_runner.py | 4 ++--
airflow-core/src/airflow/models/dag.py | 16 +++++++++-------
airflow-core/tests/unit/jobs/test_scheduler_job.py | 2 +-
airflow-core/tests/unit/models/test_dag.py | 2 +-
5 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/airflow-core/src/airflow/dag_processing/collection.py
b/airflow-core/src/airflow/dag_processing/collection.py
index 16ca8a0ef24..003a4da016e 100644
--- a/airflow-core/src/airflow/dag_processing/collection.py
+++ b/airflow-core/src/airflow/dag_processing/collection.py
@@ -644,9 +644,9 @@ class DagModelOperation(NamedTuple):
dm.bundle_name = self.bundle_name
dm.bundle_version = self.bundle_version
- last_automated_run: DagRun | None = run_info.latest_run
+ reference_run: DagRun | None = run_info.latest_run
dm.exceeds_max_non_backfill = run_info.num_active_runs >=
dm.max_active_runs
- dm.calculate_dagrun_date_fields(dag,
last_automated_run=last_automated_run)
+ dm.calculate_dagrun_date_fields(dag, reference_run=reference_run)
if not dag.timetable.asset_condition:
dm.schedule_asset_references = []
dm.schedule_asset_alias_references = []
diff --git a/airflow-core/src/airflow/jobs/scheduler_job_runner.py
b/airflow-core/src/airflow/jobs/scheduler_job_runner.py
index 51178847267..6f4c3505a38 100644
--- a/airflow-core/src/airflow/jobs/scheduler_job_runner.py
+++ b/airflow-core/src/airflow/jobs/scheduler_job_runner.py
@@ -2458,7 +2458,7 @@ class SchedulerJobRunner(BaseJobRunner, LoggingMixin):
dag_id=dag_model.dag_id,
logical_date=dag_model.next_dagrun,
)
- dag_model.calculate_dagrun_date_fields(dag=serdag,
last_automated_run=dr)
+ dag_model.calculate_dagrun_date_fields(dag=serdag,
reference_run=dr)
continue
if (
@@ -2498,7 +2498,7 @@ class SchedulerJobRunner(BaseJobRunner, LoggingMixin):
partition_date=next_info.partition_date,
)
active_runs_of_dags[dag_model.dag_id] += 1
- dag_model.calculate_dagrun_date_fields(dag=serdag,
last_automated_run=created_run)
+ dag_model.calculate_dagrun_date_fields(dag=serdag,
reference_run=created_run)
self._set_exceeds_max_active_runs(
dag_model=dag_model,
session=session,
diff --git a/airflow-core/src/airflow/models/dag.py
b/airflow-core/src/airflow/models/dag.py
index adf7a5e945c..1b20a92f353 100644
--- a/airflow-core/src/airflow/models/dag.py
+++ b/airflow-core/src/airflow/models/dag.py
@@ -813,28 +813,30 @@ class DagModel(Base):
self,
dag: SerializedDAG | LazyDeserializedDAG,
*,
- last_automated_run: DagRun | None,
+ reference_run: DagRun | None,
) -> None:
"""
Calculate ``next_dagrun`` and `next_dagrun_create_after``.
:param dag: The DAG object
- :param last_automated_run: DagRun of most recent run of this dag, or
none
- if not yet scheduled.
- TODO: AIP-76 This is not always latest run! See
https://github.com/apache/airflow/issues/59618.
+ :param reference_run: The automated run used as the basis for
computing the
+ next run, or None if not yet scheduled. This is the run the
scheduler is
+ currently processing, which is not necessarily the latest run of
the dag:
+ scheduler processing order and concurrent run creation in a
distributed
+ system mean a newer run may already exist.
"""
# TODO: AIP-76 perhaps we need to add validation for manual runs
ensure consistency between
# partition_key / partition_date and run_after
- if isinstance(last_automated_run, datetime):
+ if isinstance(reference_run, datetime):
raise ValueError(
"Passing a datetime to `DagModel.calculate_dagrun_date_fields`
is not supported. "
"Provide a data interval instead."
)
last_run_info = None
- if last_automated_run:
- last_run_info =
dag.timetable.run_info_from_dag_run(dag_run=last_automated_run)
+ if reference_run:
+ last_run_info =
dag.timetable.run_info_from_dag_run(dag_run=reference_run)
next_dagrun_info =
dag.next_dagrun_info(last_automated_run_info=last_run_info)
if next_dagrun_info is None:
# there is no next dag run after the last dag run; set everything
to None
diff --git a/airflow-core/tests/unit/jobs/test_scheduler_job.py
b/airflow-core/tests/unit/jobs/test_scheduler_job.py
index af1b34423da..ff14b06eb30 100644
--- a/airflow-core/tests/unit/jobs/test_scheduler_job.py
+++ b/airflow-core/tests/unit/jobs/test_scheduler_job.py
@@ -5072,7 +5072,7 @@ class TestSchedulerJob:
bash_command="exit 1",
retries=1,
)
- dag_maker.dag_model.calculate_dagrun_date_fields(dag,
last_automated_run=None)
+ dag_maker.dag_model.calculate_dagrun_date_fields(dag,
reference_run=None)
@provide_session
def do_schedule(*, session: Session = NEW_SESSION):
diff --git a/airflow-core/tests/unit/models/test_dag.py
b/airflow-core/tests/unit/models/test_dag.py
index f09ab836b6b..da751e7dd85 100644
--- a/airflow-core/tests/unit/models/test_dag.py
+++ b/airflow-core/tests/unit/models/test_dag.py
@@ -4344,7 +4344,7 @@ def test_calculate_dagrun_date_fields(
run = dag_maker.create_dagrun()
serdag = dag_maker.serialized_dag
dag_model = dag_maker.dag_model
- dag_model.calculate_dagrun_date_fields(dag=serdag, last_automated_run=run)
+ dag_model.calculate_dagrun_date_fields(dag=serdag, reference_run=run)
assert dag_model.next_dagrun_data_interval == next_interval
assert dag_model.next_dagrun == next_run
assert dag_model.next_dagrun_create_after == next_run_after