Esempio n. 1
0
    def test_context_ignore_depends_on_past(self):
        """
        If the context overrides depends_on_past then the dep should be met,
        even though there is no previous_ti which would normally fail the dep
        """
        task = self._get_task(depends_on_past=True,
                              start_date=datetime(2016, 1, 1),
                              wait_for_downstream=False)
        prev_ti = Mock(task=task,
                       state=State.SUCCESS,
                       are_dependents_done=Mock(return_value=True),
                       execution_date=datetime(2016, 1, 2))
        ti = Mock(task=task,
                  previous_ti=prev_ti,
                  execution_date=datetime(2016, 1, 3))
        dep_context = DepContext(ignore_depends_on_past=True)

        self.assertTrue(PrevDagrunDep().is_met(ti=ti, dep_context=dep_context))
Esempio n. 2
0
    def test_not_depends_on_past(self):
        """
        If depends on past isn't set in the task then the previous dagrun should be
        ignored, even though there is no previous_ti which would normally fail the dep
        """
        task = self._get_task(
            depends_on_past=False, start_date=datetime(2016, 1, 1), wait_for_downstream=False
        )
        prev_ti = Mock(
            task=task,
            state=State.SUCCESS,
            are_dependents_done=Mock(return_value=True),
            execution_date=datetime(2016, 1, 2),
        )
        ti = Mock(task=task, previous_ti=prev_ti, execution_date=datetime(2016, 1, 3))
        dep_context = DepContext(ignore_depends_on_past=False)

        assert PrevDagrunDep().is_met(ti=ti, dep_context=dep_context)
Esempio n. 3
0
    def test_failed_wait_for_downstream(self):
        """
        If the previous TI specified to wait for the downstream tasks of the
        previous dagrun then it should fail this dep if the downstream TIs of
        the previous TI are not done.
        """
        task = self._get_task(depends_on_past=True,
                              start_date=datetime(2016, 1, 1),
                              wait_for_downstream=True)
        prev_ti = Mock(state=State.SUCCESS,
                       are_dependents_done=Mock(return_value=False))
        ti = Mock(task=task,
                  previous_ti=prev_ti,
                  execution_date=datetime(2016, 1, 2))
        dep_context = DepContext(ignore_depends_on_past=False)

        self.assertFalse(PrevDagrunDep().is_met(ti=ti,
                                                dep_context=dep_context))
Esempio n. 4
0
    def deps(self):
        """
        Returns the list of dependencies for the operator. These differ from execution
        context dependencies in that they are specific to tasks and can be
        extended/overridden by subclasses.
        """
        from airflow.ti_deps.deps.not_in_retry_period_dep import NotInRetryPeriodDep
        from airflow.ti_deps.deps.prev_dagrun_dep import PrevDagrunDep

        try:
            from dbnd_airflow.dbnd_task_executor.optimized_trigger_rule_dep import (
                TriggerRuleDepOptimizied as TriggerRuleDep,
            )
        except Exception:
            from airflow.ti_deps.deps.trigger_rule_dep import TriggerRuleDep

        return {
            NotInRetryPeriodDep(),
            PrevDagrunDep(),
            TriggerRuleDep(),  # PATCH: We replace TriggerRuleDep with TriggerRuleDepOptimizied
        }