x89
x89

Reputation: 3460

No module named 'airflow.sensors.python_sensor'

I am trying to use PythonSensor in my dag but I am unable to import it.

from airflow.sensors.python_sensor import PythonSensor
    wait_for_stg_completion = PythonSensor(
        task_id='wait_for_stg_completion',
        python_callable=fetch_stg_qa_status
    )

How can I import it? What else can I try?

Upvotes: 0

Views: 707

Answers (2)

Elad Kalif
Elad Kalif

Reputation: 15971

For Airflow < 2.0.0:

from airflow.contrib.sensors.python_sensor import PythonSensor

The PythonSensor is unique in that matter. One would expect to find it in airflow.sensors like other core sensors but that is not the case.

For Airflow >= 2.0.0:

from airflow.sensors.python import PythonSensor

You can also import from contrib but it will show deprecation warning so best to use the updated path.

Upvotes: 1

Michal Voleš&#237;ni
Michal Voleš&#237;ni

Reputation: 111

You have incorrect import. Use

from airflow.sensors.python import PythonSensor

Upvotes: 0

Related Questions