From 57bb54d458aec4bea6977b2e410107df4c281de6 Mon Sep 17 00:00:00 2001 From: Ryan Hatter <25823361+RNHTTR@users.noreply.github.com> Date: Sun, 23 Oct 2022 11:12:30 -0400 Subject: [PATCH] set executor.job_id to BackfillJob.id for backfills (#27020) Co-authored-by: Ryan Hatter --- airflow/jobs/backfill_job.py | 2 +- tests/jobs/test_backfill_job.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/airflow/jobs/backfill_job.py b/airflow/jobs/backfill_job.py index 62bc8c2bb308f..018a70ea8e3aa 100644 --- a/airflow/jobs/backfill_job.py +++ b/airflow/jobs/backfill_job.py @@ -833,7 +833,7 @@ def _execute(self, session=None): pickle_id = pickle.id executor = self.executor - executor.job_id = "backfill" + executor.job_id = self.id executor.start() ti_status.total_runs = len(dagrun_infos) # total dag runs in backfill diff --git a/tests/jobs/test_backfill_job.py b/tests/jobs/test_backfill_job.py index 18fa630835a50..2071f56c37c03 100644 --- a/tests/jobs/test_backfill_job.py +++ b/tests/jobs/test_backfill_job.py @@ -1609,8 +1609,8 @@ def test_job_id_is_assigned_to_dag_run(self, dag_maker): dr: DagRun = dag.get_last_dagrun() assert dr.creating_job_id == job.id - def test_backfill_has_job_id(self): - """Make sure that backfill jobs are assigned job_ids.""" + def test_backfill_has_job_id_int(self): + """Make sure that backfill jobs are assigned job_ids and that the job_id is an int.""" dag = self.dagbag.get_dag("test_start_date_scheduling") dag.clear() @@ -1624,7 +1624,7 @@ def test_backfill_has_job_id(self): run_backwards=True, ) job.run() - assert executor.job_id is not None + assert isinstance(executor.job_id, int) @pytest.mark.long_running @pytest.mark.parametrize("executor_name", ["SequentialExecutor", "DebugExecutor"])