[v3-0-test] Fix Jinja2 Template deep copy error with dag.test (#51670)
#51673
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
dag.testmethod currently (in 3.0.2) clears dag runs before running ( code ) the dag. For that it usesSchedulerDAG.clear_dags, which createSchedulerDAGfrom Task SDK DAG -- to do that it usesdeepcopy.copy.Now that works for most cases, but not where
jinja2.Templateclass is passed as a Task/Operator argument because of this issue.This is a general issue that can affect any DAG using custom arguments that store or cache Jinja2 Template objects or similar.
Clearly, the longer term solution for dag.test is to not use SchedulerDAG like that and instead call some task Execution endpoint to clear dagruns -- but this works for 3.0.x.
(cherry picked from commit 75f8aa9)
Co-authored-by: Kaxil Naik kaxilnaik@gmail.com