batch_test.py 1.09 KB
Newer Older
김진영's avatar
김진영 committed
1
2
from datetime import datetime, timedelta
from textwrap import dedent
김진영's avatar
김진영 committed
3
import pendulum
김진영's avatar
김진영 committed
4
5
6
7

# The DAG object; we'll need this to instantiate a DAG
from airflow import DAG

김진영's avatar
김진영 committed
8
9
local_tz = pendulum.timezone("Asia/Seoul")

김진영's avatar
김진영 committed
10
11
12
13
14
15
# Operators; we need this to operate!
from airflow.operators.bash import BashOperator
with DAG(
    'batch_test',
    default_args={
        'depends_on_past': False,
김진영's avatar
김진영 committed
16
        'email': 'kim-jy@lotte.net',
김진영's avatar
김진영 committed
17
18
    },
    description='Test Batch Job',
김진영's avatar
김진영 committed
19
    schedule_interval='*/1 * * * *',
김진영's avatar
김진영 committed
20
    start_date=datetime(2022, 5, 13, tzinfo=local_tz),
김진영's avatar
김진영 committed
21
    tags=['test'],
김진영's avatar
김진영 committed
22
    catchup=False,
김진영's avatar
김진영 committed
23
) as dag:
김진영's avatar
김진영 committed
24
25
    # gasan 작업 병렬처리
    post_gasan_tasks = []
김진영's avatar
김진영 committed
26

김진영's avatar
김진영 committed
27
28
29
30
31
    for i in range(4):
        post_gasan_task = BashOperator(
            task_id='post_gasan'+str(i),
            bash_command="curl -X \'POST\' \'http://10.231.238.224:30999/api/v1/camera/writeimage\' -H \'Content-Type: application/json\' -d \'{\"id\": \"test%s\", \"pw\": \"test\", \"ip\": \"10.123.123.1\", \"serialNum\": \"aaaa\", \"camName\": \"abc\"}\'" %(str(i)),
        )
김진영's avatar
김진영 committed
32

김진영's avatar
김진영 committed
33
        post_gasan_tasks.append(post_gasan_task)
김진영's avatar
김진영 committed
34

김진영's avatar
김진영 committed
35
36
    post_gasan_tasks
    # t1