Skip to content

Commit 6594b1b

Browse files
coder2jcoder2j
coder2j
authored and
coder2j
committed
MINOR: Add tutorial of Airflow AWS S3 Sensor
1 parent b61895a commit 6594b1b

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

README.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
1-
# airflow-docker
1+
# Apache Airflow Tutorial Series [YouTube](https://www.youtube.com/watch?v=z7xyNOF8tak&list=PLwFJcsJ61oujAqYpMp1kdUBcPG0sE0QMT)
2+
## Updated Tutorial Episode
3+
1. [Introduction and Local Installation](https://youtu.be/z7xyNOF8tak)
4+
2. [Get Airflow running in Docker](https://youtu.be/J6azvFhndLg)
5+
3. [Airflow Core Concepts in 5 mins](https://youtu.be/mtJHMdoi_Gg)
6+
4. [Airflow Task Lifecycle and Basic Architecture](https://youtu.be/UFsCvWjQT4w)
7+
5. [Airflow DAG with BashOperator](https://youtu.be/CLkzXrjrFKg)
8+
6. [Airflow DAG with PythonOperator and XComs](https://youtu.be/IumQX-mm20Y)
9+
7. [Airflow TaskFlow API](https://youtu.be/9y0mqWsok_4)
10+
8. [Airflow Catchup and Backfill](https://youtu.be/OXOiUeHOQ-0)
11+
9. [Schedule Airflow DAG with Cron Expression](https://youtu.be/tpuovQFUByk)
12+
10. [Airflow Connection and PostgresOperator](https://youtu.be/S1eapG6gjLU)
13+
11. [Add Python Dependencies via Airflow Docker Image Extending and Customizing](https://youtu.be/0UepvC9X4HY)
14+
12. [AWS S3 Key Sensor Operator](https://youtu.be/vuxrhipJMCk)
15+
216
## Running apache airflow 2.0 in docker with local executor.
317
Here are the steps to take to get airflow 2.0 running with docker on your machine.
418
1. Clone this repo
5-
2. Create dags, logs and plugins folder inside the project directory
19+
1. Create dags, logs and plugins folder inside the project directory
620
```bash
721
mkdir ./dags ./logs ./plugins
822
```
9-
3. Install docker desktop application if you don't have docker running on your machine
23+
1. Install docker desktop application if you don't have docker running on your machine
1024
- [Download Docker Desktop Application for Mac OS](https://hub.docker.com/editions/community/docker-ce-desktop-mac)
1125
- [Download Docker Desktop Application for Windows](https://hub.docker.com/editions/community/docker-ce-desktop-windows)
12-
4. Launch airflow by docker-compose
26+
1. Launch airflow by docker-compose
1327
```bash
1428
docker-compose up -d
1529
```
16-
5. Check the running containers
30+
1. Check the running containers
1731
```bash
1832
docker ps
1933
```
20-
6. Open browser and type http://0.0.0.0:800 to launch the airflow webserver
34+
1. Open browser and type http://0.0.0.0:800 to launch the airflow webserver
2135

2236
![](images/screenshot_airflow_docker.png)

dags/dag_with_minio_s3.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from datetime import datetime, timedelta
2+
3+
from airflow import DAG
4+
from airflow.providers.amazon.aws.sensors.s3_key import S3KeySensor
5+
6+
7+
default_args = {
8+
'owner': 'coder2j',
9+
'retries': 5,
10+
'retry_delay': timedelta(minutes=10)
11+
}
12+
13+
14+
with DAG(
15+
dag_id='dag_with_minio_s3_v02',
16+
start_date=datetime(2022, 2, 12),
17+
schedule_interval='@daily',
18+
default_args=default_args
19+
) as dag:
20+
task1 = S3KeySensor(
21+
task_id='sensor_minio_s3',
22+
bucket_name='airflow',
23+
bucket_key='data.csv',
24+
aws_conn_id='minio_conn',
25+
mode='poke',
26+
poke_interval=5,
27+
timeout=30
28+
)

data/data.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
product_id, delivery_dt
2+
10005, 2022-01-01
3+
10001, 2021-12-30

0 commit comments

Comments
 (0)