-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathreprocess_unvalidated_notices_from_backlog.py
More file actions
50 lines (42 loc) · 2.28 KB
/
reprocess_unvalidated_notices_from_backlog.py
File metadata and controls
50 lines (42 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from airflow.decorators import dag, task
from dags import DEFAULT_DAG_ARGUMENTS, NOTICE_TRANSFORMATION_PIPELINE_TASK_ID
from dags.dags_utils import push_dag_downstream, get_dag_param
from dags.operators.DagBatchPipelineOperator import NOTICE_IDS_KEY, TriggerNoticeBatchPipelineOperator
from dags.pipelines.notice_selectors_pipelines import notice_ids_selector_by_status
from ted_sws.core.model.notice import NoticeStatus
from ted_sws.event_manager.adapters.event_log_decorator import event_log
from ted_sws.event_manager.model.event_message import TechnicalEventMessage, EventMessageMetadata, \
EventMessageProcessType
DAG_NAME = "reprocess_unvalidated_notices_from_backlog"
RE_VALIDATE_TARGET_NOTICE_STATES = [NoticeStatus.DISTILLED]
TRIGGER_NOTICE_PROCESS_WORKFLOW_TASK_ID = "trigger_notice_process_workflow"
FORM_NUMBER_DAG_PARAM = "form_number"
START_DATE_DAG_PARAM = "start_date"
END_DATE_DAG_PARAM = "end_date"
XSD_VERSION_DAG_PARAM = "xsd_version"
@dag(default_args=DEFAULT_DAG_ARGUMENTS,
schedule_interval=None,
tags=['selector', 're-validate'])
def reprocess_unvalidated_notices_from_backlog():
@task
@event_log(TechnicalEventMessage(
message="select_notices_for_re_validate",
metadata=EventMessageMetadata(
process_type=EventMessageProcessType.DAG, process_name=DAG_NAME
))
)
def select_notices_for_re_validate():
form_number = get_dag_param(key=FORM_NUMBER_DAG_PARAM)
start_date = get_dag_param(key=START_DATE_DAG_PARAM)
end_date = get_dag_param(key=END_DATE_DAG_PARAM)
xsd_version = get_dag_param(key=XSD_VERSION_DAG_PARAM)
notice_ids = notice_ids_selector_by_status(notice_statuses=RE_VALIDATE_TARGET_NOTICE_STATES,
form_number=form_number, start_date=start_date,
end_date=end_date, xsd_version=xsd_version)
push_dag_downstream(key=NOTICE_IDS_KEY, value=notice_ids)
trigger_notice_process_workflow = TriggerNoticeBatchPipelineOperator(
task_id=TRIGGER_NOTICE_PROCESS_WORKFLOW_TASK_ID,
start_with_step_name=NOTICE_TRANSFORMATION_PIPELINE_TASK_ID
)
select_notices_for_re_validate() >> trigger_notice_process_workflow
dag = reprocess_unvalidated_notices_from_backlog()