Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
김진영
airflow-test
Commits
86db31b0
Commit
86db31b0
authored
May 23, 2022
by
김진영
Browse files
Update bc-mart.py
parent
9897d45b
Changes
1
Hide whitespace changes
Inline
Side-by-side
bc-mart.py
View file @
86db31b0
...
@@ -4,7 +4,7 @@ import pendulum
...
@@ -4,7 +4,7 @@ import pendulum
from
airflow.operators.bash
import
BashOperator
from
airflow.operators.bash
import
BashOperator
from
airflow
import
DAG
from
airflow
import
DAG
from
airflow.models
import
Variable
from
airflow.models
import
Variable
from
data.
gasan
_data
import
gasan
Data
# import
gasan
data
from
data.
mart
_data
import
mart
Data
# import
mart
data
from
fail_alert
import
fail_alert
# 실패 시 Teams 알림 발송
from
fail_alert
import
fail_alert
# 실패 시 Teams 알림 발송
# set timezone
# set timezone
...
@@ -19,7 +19,7 @@ with DAG(
...
@@ -19,7 +19,7 @@ with DAG(
#'on_failure_callback': fail_alert
#'on_failure_callback': fail_alert
'on_success_callback'
:
fail_alert
'on_success_callback'
:
fail_alert
},
},
description
=
'dag for
gasan
batch jobs'
,
description
=
'dag for
mart
batch jobs'
,
schedule_interval
=
'*/1 * * * *'
,
schedule_interval
=
'*/1 * * * *'
,
start_date
=
datetime
(
2022
,
5
,
13
,
tzinfo
=
local_tz
),
start_date
=
datetime
(
2022
,
5
,
13
,
tzinfo
=
local_tz
),
tags
=
[
'test'
],
tags
=
[
'test'
],
...
@@ -33,11 +33,11 @@ with DAG(
...
@@ -33,11 +33,11 @@ with DAG(
),
),
)
)
# (Task2)
gasan
작업 병렬처리
# (Task2)
mart
작업 병렬처리
post_
gasan
_tasks
=
[]
post_
mart
_tasks
=
[]
for
i
,
data
in
enumerate
(
gasan
Data
):
for
i
,
data
in
enumerate
(
mart
Data
):
post_
gasan
_task
=
BashOperator
(
post_
mart
_task
=
BashOperator
(
task_id
=
'post_gasan'
+
str
(
i
+
1
),
task_id
=
'post_gasan'
+
str
(
i
+
1
),
bash_command
=
"curl -X
\'
POST
\'
\'
%s/api/v1/camera/writeimage
\'
-H
\'
Content-Type: application/json
\'
-d
\'
{
\"
id
\"
:
\"
%s
\"
,
\"
%s
\"
:
\"
test
\"
,
\"
ip
\"
:
\"
%s
\"
,
\"
serialNum
\"
:
\"
%s
\"
,
\"
camName
\"
:
\"
%s
\"
}
\'
"
%
(
bash_command
=
"curl -X
\'
POST
\'
\'
%s/api/v1/camera/writeimage
\'
-H
\'
Content-Type: application/json
\'
-d
\'
{
\"
id
\"
:
\"
%s
\"
,
\"
%s
\"
:
\"
test
\"
,
\"
ip
\"
:
\"
%s
\"
,
\"
serialNum
\"
:
\"
%s
\"
,
\"
camName
\"
:
\"
%s
\"
}
\'
"
%
(
Variable
.
get
(
"INF_API_URL"
),
Variable
.
get
(
"INF_API_URL"
),
...
@@ -49,7 +49,7 @@ with DAG(
...
@@ -49,7 +49,7 @@ with DAG(
),
),
)
)
post_
gasan
_tasks
.
append
(
post_
gasan
_task
)
post_
mart
_tasks
.
append
(
post_
mart
_task
)
# 작업 순서 정의
# 작업 순서 정의
health_check
>>
post_
gasan
_tasks
health_check
>>
post_
mart
_tasks
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment