|
| 1 | +from airflow.decorators import dag, task |
| 2 | + |
| 3 | +from dags import DEFAULT_DAG_ARGUMENTS |
| 4 | +from dags.dags_utils import push_dag_downstream, get_dag_param |
| 5 | +from dags.notice_processing_pipeline import NOTICE_TRANSFORMATION_PIPELINE_TASK_ID |
| 6 | +from dags.operators.DagBatchPipelineOperator import NOTICE_IDS_KEY, TriggerNoticeBatchPipelineOperator, \ |
| 7 | + EXECUTE_ONLY_ONE_STEP_KEY |
| 8 | +from dags.pipelines.notice_selectors_pipelines import notice_ids_selector_by_status |
| 9 | +from ted_sws.core.model.notice import NoticeStatus |
| 10 | +from ted_sws.event_manager.adapters.event_log_decorator import event_log |
| 11 | +from ted_sws.event_manager.model.event_message import TechnicalEventMessage, EventMessageMetadata, \ |
| 12 | + EventMessageProcessType |
| 13 | + |
| 14 | +DAG_NAME = "reprocess_published_in_cellar_notices" |
| 15 | + |
| 16 | +RE_TRANSFORM_TARGET_NOTICE_STATES = [NoticeStatus.PUBLICLY_AVAILABLE] |
| 17 | +TRIGGER_NOTICE_PROCESS_WORKFLOW_TASK_ID = "trigger_notice_process_workflow" |
| 18 | +FORM_NUMBER_DAG_PARAM = "form_number" |
| 19 | +START_DATE_DAG_PARAM = "start_date" |
| 20 | +END_DATE_DAG_PARAM = "end_date" |
| 21 | +XSD_VERSION_DAG_PARAM = "xsd_version" |
| 22 | + |
| 23 | + |
| 24 | +@dag(default_args=DEFAULT_DAG_ARGUMENTS, |
| 25 | + schedule_interval=None, |
| 26 | + tags=['selector', 're-transform-publicly-available']) |
| 27 | +def reprocess_published_in_cellar_notices(): |
| 28 | + @task |
| 29 | + @event_log(TechnicalEventMessage( |
| 30 | + message="select_notices_for_re_transform", |
| 31 | + metadata=EventMessageMetadata( |
| 32 | + process_type=EventMessageProcessType.DAG, process_name=DAG_NAME |
| 33 | + )) |
| 34 | + ) |
| 35 | + def select_notices_for_re_transform(): |
| 36 | + form_number = get_dag_param(key=FORM_NUMBER_DAG_PARAM) |
| 37 | + start_date = get_dag_param(key=START_DATE_DAG_PARAM) |
| 38 | + end_date = get_dag_param(key=END_DATE_DAG_PARAM) |
| 39 | + xsd_version = get_dag_param(key=XSD_VERSION_DAG_PARAM) |
| 40 | + notice_ids = notice_ids_selector_by_status(notice_statuses=RE_TRANSFORM_TARGET_NOTICE_STATES, |
| 41 | + form_number=form_number, start_date=start_date, |
| 42 | + end_date=end_date, xsd_version=xsd_version) |
| 43 | + push_dag_downstream(key=NOTICE_IDS_KEY, value=notice_ids) |
| 44 | + |
| 45 | + trigger_notice_process_workflow = TriggerNoticeBatchPipelineOperator( |
| 46 | + task_id=TRIGGER_NOTICE_PROCESS_WORKFLOW_TASK_ID, |
| 47 | + start_with_step_name=NOTICE_TRANSFORMATION_PIPELINE_TASK_ID |
| 48 | + ) |
| 49 | + select_notices_for_re_transform() >> trigger_notice_process_workflow |
| 50 | + |
| 51 | + |
| 52 | +dag = reprocess_published_in_cellar_notices() |
0 commit comments