-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Description
Apache Airflow version
3.0.3
If "Other Airflow 2 version" selected, which one?
No response
What happened?
Previously, in 2.9.2, I used the dag_run available in the task context and called get_previous_dagrun on it, but from what I understand in Airflow 3 the context holds a stripped down version of the dag_run, which no longer has the get_previous_dagrun method.
Instead, in Airflow 3.0.2 the call fails with:
AttributeError: 'DagRun' object has no attribute 'get_previous_dagrun'
What you think should happen instead?
I think there should be a get_previous_dagrun method as before. The reason I used this in 2.9.2 was to get the state of the previous DagRun and based on the current and previous state decided whether to send a notification or not (e.g.: if a DAG fails, we might only care to get a notification on the first failure or when it recovers, not in between)
How to reproduce
For reference, the code that works in 2.9.2 looks like this:
crt_dag_run = context["dag_run"] previous_dag_run = crt_dag_run.get_previous_dagrun(dag_run=crt_dag_run)
In v3, the DagRun that I get is of type airflow.sdk.api.datamodels._generated.DagRun which doesn't contain the get_previous_dagrun method.
Operating System
Debian GNU/Linux 12 (bookworm)
Versions of Apache Airflow Providers
apache-airflow-providers-cncf-kubernetes 10.6.1
apache-airflow-providers-standard 1.4.0
Deployment
Official Apache Airflow Helm Chart
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct