Commit d77172e0 authored by 김진영's avatar 김진영
Browse files

Update bc-super.py

parent 52e1a075
......@@ -4,7 +4,7 @@ import pendulum
from airflow.operators.bash import BashOperator
from airflow import DAG
from airflow.models import Variable
from data.mart_data import martData # import mart data
from data.super_data import superData # import super data
from fail_alert import fail_alert # 실패 시 Teams 알림 발송
# set timezone
......@@ -19,7 +19,7 @@ with DAG(
#'on_failure_callback': fail_alert
'on_success_callback': fail_alert
},
description='dag for mart batch jobs',
description='dag for super batch jobs',
schedule_interval='*/1 * * * *',
start_date=datetime(2022, 5, 13, tzinfo=local_tz),
tags=['test'],
......@@ -28,18 +28,18 @@ with DAG(
# (Task1) 헬스체크
health_check = BashOperator(
task_id='health_check',
bash_command="curl -X GET -v {api_url}/api/v1/core/health \'-H accept: application/json\'".format(
bash_command="sleep 70; curl -X GET -v {api_url}/api/v1/core/health \'-H accept: application/json\'".format(
api_url=Variable.get("INF_API_URL")
),
)
# (Task2) mart 작업 병렬처리
post_mart_tasks = []
# (Task2) super 작업 병렬처리
post_super_tasks = []
for i, data in enumerate(martData):
post_mart_task = BashOperator(
task_id='post_mart'+str(i+1),
bash_command="sleep 30; curl -X \'POST\' \'%s/api/v1/camera/mart/writeimage\' -H \'Content-Type: application/json\' -d \'{\"id\": \"%s\", \"pw\": \"%s\", \"ip\": \"%s\", \"serialNum\": \"%s\", \"camName\": \"%s\"}\'" %(
for i, data in enumerate(superData):
post_super_task = BashOperator(
task_id='post_super'+str(i+1),
bash_command="sleep 30; curl -X \'POST\' \'%s/api/v1/camera/super/writeimage\' -H \'Content-Type: application/json\' -d \'{\"id\": \"%s\", \"pw\": \"%s\", \"ip\": \"%s\", \"serialNum\": \"%s\", \"camName\": \"%s\"}\'" %(
Variable.get("INF_API_URL"),
Variable.get("INF_API_ID"),
Variable.get("INF_API_PW"),
......@@ -49,7 +49,7 @@ with DAG(
),
)
post_mart_tasks.append(post_mart_task)
post_super_tasks.append(post_super_task)
# 작업 순서 정의
health_check >> post_mart_tasks
health_check >> post_super_tasks
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment