question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`TriggerDagRunOperator` raises a `DeprecationWarning`

See original GitHub issue

Apache Airflow version

2.2.5 (latest released)

What happened

When I’m using the airflow.operators.trigger_dagrun.TriggerDagRunOperator, the following DeprecationWarning is raised:

[2022-04-20 17:59:09,618] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/api/common/trigger_dag.py:84 DeprecationWarning: Calling `DAG.create_dagrun()` without an explicit data interval is deprecated

What you think should happen instead

Run the DAG without raising any warnings.

How to reproduce

Given the following two DAGs:

from datetime import datetime

from airflow import DAG
from airflow.operators.dummy import DummyOperator
from airflow.operators.trigger_dagrun import TriggerDagRunOperator

dag_a = DAG(
    dag_id='a',
    start_date=datetime(2021, 10, 21),
    schedule_interval='30 4 * * *',
    catchup=False,
)

with dag_a:
    task_a = DummyOperator(task_id='foo')

dag_a_yesterday = DAG(
    dag_id='a_yesterday',
    start_date=datetime(2021, 10, 21),
    schedule_interval='@once',
    catchup=False,
)

with dag_a_yesterday:
    task_b = TriggerDagRunOperator(
        task_id='trigger_dag_a_yesterday',
        trigger_dag_id='a',
        wait_for_completion=True,
        execution_date='{{ data_interval_start.subtract(days=1, minutes=-1) }}'
    )

and after triggering the a_yesterday DAG:

$ astro airflow run dags trigger a_yesterday -e '2022-04-20 00:00:01'

I’m getting the following warning:

$ docker exec -it webserver tail -n 10 /usr/local/airflow/logs/a_yesterday/trigger_dag_a_yesterday/2022-04-20T00:00:01+00:00/1.log
AIRFLOW_CTX_DAG_ID=a_yesterday
AIRFLOW_CTX_TASK_ID=trigger_dag_a_yesterday
AIRFLOW_CTX_EXECUTION_DATE=2022-04-20T00:00:01+00:00
AIRFLOW_CTX_DAG_RUN_ID=manual__2022-04-20T00:00:01+00:00
[2022-04-20 17:59:09,618] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/api/common/trigger_dag.py:84 DeprecationWarning: Calling `DAG.create_dagrun()` without an explicit data interval is deprecated
[2022-04-20 17:59:09,662] {trigger_dagrun.py:178} INFO - Waiting for a on 2022-04-19T00:01:01+00:00 to become allowed state ['success'] ...
[2022-04-20 18:00:09,768] {trigger_dagrun.py:178} INFO - Waiting for a on 2022-04-19T00:01:01+00:00 to become allowed state ['success'] ...
[2022-04-20 18:01:09,871] {trigger_dagrun.py:178} INFO - Waiting for a on 2022-04-19T00:01:01+00:00 to become allowed state ['success'] ...
[2022-04-20 18:02:09,977] {trigger_dagrun.py:178} INFO - Waiting for a on 2022-04-19T00:01:01+00:00 to become allowed state ['success'] ...
[2022-04-20 18:03:10,080] {trigger_dagrun.py:178} INFO - Waiting for a on 2022-04-19T00:01:01+00:00 to become allowed state ['success'] ...

Operating System

Pop!_OS 20.04 LTS

Versions of Apache Airflow Providers

apache-airflow-providers-amazon==1!3.2.0
apache-airflow-providers-cncf-kubernetes==1!3.0.0
apache-airflow-providers-elasticsearch==1!2.2.0
apache-airflow-providers-ftp==1!2.1.2
apache-airflow-providers-google==1!6.7.0
apache-airflow-providers-http==1!2.1.2
apache-airflow-providers-imap==1!2.2.3
apache-airflow-providers-microsoft-azure==1!3.7.2
apache-airflow-providers-mysql==1!2.2.3
apache-airflow-providers-postgres==1!4.1.0
apache-airflow-providers-redis==1!2.0.4
apache-airflow-providers-slack==1!4.2.3
apache-airflow-providers-sqlite==1!2.1.3
apache-airflow-providers-ssh==1!2.4.3

Deployment

Astronomer

Deployment details

docker-compose version 1.29.2, build 5becea4c Docker version 20.10.14, build a224086 Astronomer docker image: quay.io/astronomer/ap-airflow:2.2.5-2-onbuild

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tirkarthicommented, Apr 25, 2022

The referenced PR commit is available from 2.3.0b1 and above : https://github.com/apache/airflow/commit/82e466d8f9b196e1efba44cc15214b9d0bd3b2d1 . Perhaps it needs to be backported/cherry-picked to v2-2-stable branch

https://airflow.apache.org/docs/apache-airflow/stable/release-process.html

1reaction
harishkraocommented, Apr 21, 2022

Given the recently added tags by @uranusjr , I suppose this warning needs a fix. Although I’m airflow newbie, I would like to give it a try.

Sure, please do. Thanks for letting me know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Release Notes — Airflow Documentation
Migrated components remain backwards compatible but raise a DeprecationWarning when imported from the old module. Migrated are: ...
Read more >
Updating Airflow
A deprecation warning has also been raised for paths importing with the suffix. ... TriggerDagRunOperator, airflow.operators.trigger_dagrun.
Read more >
Can I use a TriggerDagRunOperator to pass a parameter to ...
Here is an example that demonstrates how to set the conf sent with dagruns triggered by TriggerDagRunOperator (in 1.10.11). trigger.py
Read more >
Airflow Documentation - Read the Docs
If the script does not raise an exception it means that you haven't done anything horribly wrong, and that your Airflow.
Read more >
warnings — Warning control — Python 3.11.1 documentation
For instance, do the following to capture all raised warnings to check: import warnings def fxn(): warnings.warn("deprecated", DeprecationWarning) with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found