liveBook · Manning

FileSensor

As explained in Data Pipelines with Apache Airflow, Second Edition

FileSensor is an Airflow sensor that checks whether a file exists at a specified path.

When external data arrives unpredictably, a FileSensor lets an Airflow DAG start checking immediately instead of waiting for a fixed delivery time. It repeatedly tests whether a specified path exists, succeeding when the file appears and continuing to wait while it is absent. section 7.1

Wait for a supermarket file

from airflow.providers.standard.sensors.filesystem import FileSensor wait_for_supermarket_1 = FileSensor( task_id="wait_for_supermarket_1", filepath="/data/supermarket1/data.csv", ) The sensor pokes by default every 60 seconds. Set poke_interval to change that cadence, and configure a timeout to stop waiting after a limit. Avoid intervals so short that repeated checks overload the target system. section 7.1

A matching filename does not always mean that an upload is complete. FileSensor supports glob patterns such as data-*.csv, but it may succeed after only the first file arrives. Use a final _SUCCESS marker to signal completeness, or use PythonSensor when the condition must verify both data files and the marker. section 7.1.1

How Data Pipelines with Apache Airflow, Second Edition covers it

How deep it goes
Explains polling, success, retry intervals, and timeouts, then defers complex completeness checks to PythonSensor.
Examples
Uses a supermarket data.csv path, data-*.csv wildcards, and a _SUCCESS upload marker.
What it assumes
Assumes basic Airflow DAG and operator knowledge while introducing sensors as a specialized operator type.
What you can do after
Operate/configure FileSensor tasks with file paths, polling intervals, and timeout behavior.
How it connects
Connects FileSensor with Airflow operators, DAG scheduling, timeouts, globbing, and PythonSensor.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Pipelines with Apache Airflow, Second Edition. The section links point to the parts of the book it draws on.