Load the correct DAG version when a task starts from a trigger#69988
Load the correct DAG version when a task starts from a trigger#69988seanghaeli wants to merge 1 commit into
Conversation
5e55a88 to
f157049
Compare
f157049 to
ecbf158
Compare
|
@o-nikolas this one is similar in spirit to your PR #69941 |
|
|
||
|
|
||
| def test_create_workload_resolves_serialized_dag_from_run_created_version(jobless_supervisor, mocker): | ||
| """If the run and the task point at different DAG versions, the trigger should load the run's version.""" |
There was a problem hiding this comment.
It should be "Dag", not "DAG".
| version_id=trigger.task_instance.get_dagrun(session=session).created_dag_version_id | ||
| or trigger.task_instance.dag_version_id, |
There was a problem hiding this comment.
created_dag_version_id is populated even for Dags with disable_bundle_versioning=True; dag_run.bundle_version is what determines
whether the run is pinned. This unconditional preference for created_dag_version_id therefore makes an unpinned start_from_trigger task load the Dag version from when the run was created, even after the scheduler has advanced the unfinished TI's dag_version_id following a reparse.
This differs from DBDagBag._version_from_dag_run(), which intentionally resolves the latest version when bundle_version is absent. Please use the run's created_dag_version_id only when the run is pinned, retain the TI version for unpinned runs, and cover both cases in the regression test.
There was a problem hiding this comment.
Please expand the test to cover both pinned and unpinned cases and set dag_run.bundle_version explicitly.
Also, please add spec/autospec to the new mocks and remove assert run_version != umped_ti_version; that assertion tests uuid.uuid4() rather than behavior introduced by this PR.
If the run and the task point at different DAG versions, the trigger should load the run's version.