0
0
Apache Airflowdevops~10 mins

FileSensor for file arrival detection in Apache Airflow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the FileSensor class from Airflow sensors.

Apache Airflow
from airflow.sensors.filesystem import [1]
Drag options to blanks, or click blank then click option'
AFileSensor
BHttpSensor
CTimeSensor
DS3KeySensor
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong sensor class like HttpSensor or TimeSensor.
2fill in blank
medium

Complete the code to create a FileSensor that checks for a file named 'data.csv' in '/tmp'.

Apache Airflow
file_sensor = FileSensor(task_id='check_file', filepath='/tmp/[1]')
Drag options to blanks, or click blank then click option'
Ainput.txt
Breport.pdf
Cdata.csv
Dconfig.yaml
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong file name that does not exist or is not intended to be detected.
3fill in blank
hard

Fix the error in the FileSensor initialization by completing the missing parameter for poke interval in seconds.

Apache Airflow
file_sensor = FileSensor(task_id='check_file', filepath='/tmp/data.csv', poke_interval=[1])
Drag options to blanks, or click blank then click option'
A0.5
B5
C'five'
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of an integer.
Using a negative or zero value.
4fill in blank
hard

Fill both blanks to create a FileSensor that waits for 'report.txt' in '/data' and times out after 60 seconds.

Apache Airflow
file_sensor = FileSensor(task_id='wait_report', filepath='/data/[1]', timeout=[2])
Drag options to blanks, or click blank then click option'
Areport.txt
Bdata.csv
C60
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong file name or timeout value.
5fill in blank
hard

Fill all three blanks to create a FileSensor that waits for 'config.json' in '/configs', checks every 10 seconds, and times out after 120 seconds.

Apache Airflow
file_sensor = FileSensor(task_id='wait_config', filepath='/configs/[1]', poke_interval=[2], timeout=[3])
Drag options to blanks, or click blank then click option'
Aconfig.json
B10
C120
D60
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up poke_interval and timeout values.
Using wrong file name.