'Airflow upgrade (1.10.10 to 2.2.2) - Import Error:- Cannot import name "DUMMY OPERATOR"

We are planning to upgrade Airflow 1.10.10 to Airflow 2.2.2, and currently are in testing phase to mitigate issues encountered in the migration process. Encountered one issue with DummyOperator.

In 1.10.10, the following import works fine:

from airflow.operators import DummyOperator

In 2.2.2, it gives following error:

Import Error:- Cannot import name "DUMMY OPERATOR" from airflow operators

I am able to solve this issue by using below import:

from airflow.operators.dummy import DummyOperator

Is there any way to mitigate this without changing each DAG codes as we have 1000+ DAGs in production?

Thanks!



Solution 1:[1]

Not possible. You can expect breaking changes in major versions, in Airflow 2.0 the package structure was reorganized. There has been a deprecation warning about importing from airflow.operators since Airflow 1.8.0 released in 2017.

The Airflow documentation shows steps required for migrating from Airflow 1 to 2: https://airflow.apache.org/docs/apache-airflow/stable/upgrading-from-1-10.

Any IDE should be able to help doing a search & replace, rather than having to change 1000+ DAG files manually.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1