Skip to content

Commit 6101f75

Browse files
authored
Update FilesyetmSensor test to defer (#489)
1 parent 5fa1f82 commit 6101f75

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

astronomer/providers/core/example_dags/example_file_async_sensor.txt

Whitespace-only changes.

astronomer/providers/core/example_dags/example_file_sensor.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from datetime import timedelta
33

44
from airflow import DAG
5+
from airflow.operators.bash import BashOperator
6+
from airflow.operators.empty import EmptyOperator
57
from airflow.utils.timezone import datetime
68

79
from astronomer.providers.core.sensors.filesystem import FileSensorAsync
@@ -24,10 +26,30 @@
2426
default_args=default_args,
2527
tags=["example", "async", "core"],
2628
) as dag:
29+
start = EmptyOperator(task_id="start")
30+
31+
create_file = BashOperator(
32+
task_id="create_file",
33+
bash_command="sleep 10 && touch /usr/local/airflow/dags/example_file_async_sensor.txt",
34+
)
35+
2736
# [START howto_sensor_filesystem_async]
2837
file_sensor_task = FileSensorAsync(
2938
task_id="file_sensor_task",
30-
filepath="example_file_async_sensor.txt",
39+
filepath="/usr/local/airflow/dags/example_file_async_sensor.txt",
3140
fs_conn_id=FS_CONN_ID,
41+
poke_interval=3,
3242
)
3343
# [END howto_sensor_filesystem_async]
44+
45+
delete_file = BashOperator(
46+
task_id="delete_file",
47+
bash_command="rm /usr/local/airflow/dags/example_file_async_sensor.txt",
48+
trigger_rule="all_done",
49+
)
50+
51+
end = EmptyOperator(task_id="end")
52+
53+
start >> [file_sensor_task, create_file]
54+
[create_file, file_sensor_task] >> delete_file
55+
[file_sensor_task, create_file, delete_file] >> end

0 commit comments

Comments
 (0)