Esempio n. 1
0
    def get_concurrency_check(self, task_id=dn.CONCURRENCY_CHECK):
        """Generate the concurrency check step

        Concurrency check prevents simultaneous execution of dags that should
        not execute together.
        """
        return ConcurrencyCheckOperator(
            task_id=task_id,
            on_failure_callback=step_failure_handler,
            dag=self.dag)
Esempio n. 2
0
def dag_concurrency_check(parent_dag_name, child_dag_name, args):
    '''
    dag_concurrency_check is a sub-DAG that will will allow for a DAG to
    determine if it is already running, and result in an error if so.
    '''
    dag = DAG(
        '{}.{}'.format(parent_dag_name, child_dag_name),
        default_args=args,
    )

    dag_concurrency_check_operator = ConcurrencyCheckOperator(
        task_id='dag_concurrency_check', dag=dag)

    return dag
Esempio n. 3
0
Operators
"""


def xcom_push(**kwargs):
    # Pushes action XCom
    kwargs['ti'].xcom_push(key='action',
                           value=kwargs['dag_run'].conf['action'])


action_xcom = PythonOperator(task_id='action_xcom',
                             dag=dag,
                             python_callable=xcom_push)

concurrency_check = ConcurrencyCheckOperator(
    task_id=DAG_CONCURRENCY_CHECK_DAG_NAME,
    on_failure_callback=failure_handlers.step_failure_handler,
    dag=dag)

get_design_version = SubDagOperator(
    subdag=get_design_deckhand(PARENT_DAG_NAME,
                               DECKHAND_GET_DESIGN_VERSION,
                               args=default_args),
    task_id=DECKHAND_GET_DESIGN_VERSION,
    on_failure_callback=failure_handlers.step_failure_handler,
    dag=dag)

validate_site_design = SubDagOperator(
    subdag=validate_site_design(PARENT_DAG_NAME,
                                VALIDATE_SITE_DESIGN_DAG_NAME,
                                args=default_args),
    task_id=VALIDATE_SITE_DESIGN_DAG_NAME,