Exemple #1
0
    def test_dagrun_id_is_not_backfill(self):
        """
        Task instances whose dagrun ID is not a backfill dagrun ID should pass this dep.
        """
        dagrun = DagRun()
        dagrun.run_type = 'custom_type'
        ti = Mock(get_dagrun=Mock(return_value=dagrun))
        self.assertTrue(DagrunIdDep().is_met(ti=ti))

        dagrun = DagRun()
        dagrun.run_id = None
        ti = Mock(get_dagrun=Mock(return_value=dagrun))
        self.assertTrue(DagrunIdDep().is_met(ti=ti))
 def test_dagrun_id_is_backfill(self):
     """
     Task instances whose dagrun ID is a backfill dagrun ID should fail this dep.
     """
     dagrun = DagRun()
     dagrun.run_id = f"{DagRunType.BACKFILL_JOB.value}__something"
     ti = Mock(get_dagrun=Mock(return_value=dagrun))
     self.assertFalse(DagrunIdDep().is_met(ti=ti))
Exemple #3
0
 def test_dagrun_id_is_backfill(self):
     """
     Task instances whose dagrun ID is a backfill dagrun ID should fail this dep.
     """
     dagrun = DagRun()
     dagrun.run_id = BackfillJob.ID_PREFIX + '_something'
     ti = Mock(get_dagrun=Mock(return_value=dagrun))
     self.assertFalse(DagrunIdDep().is_met(ti=ti))
Exemple #4
0
 def test_dagrun_id_is_backfill(self):
     """
     Task instances whose dagrun ID is a backfill dagrun ID should fail this dep.
     """
     dagrun = DagRun()
     dagrun.run_id = "anything"
     dagrun.run_type = DagRunType.BACKFILL_JOB
     ti = Mock(get_dagrun=Mock(return_value=dagrun))
     assert not DagrunIdDep().is_met(ti=ti)
Exemple #5
0
    DagrunRunningDep(),
    TaskNotRunningDep(),
}

# TODO(aoen): SCHEDULER_QUEUED_DEPS is not coupled to actual scheduling/execution
# in any way and could easily be modified or removed from the scheduler causing
# this dependency to become outdated and incorrect. This coupling should be created
# (e.g. via a dag_deps analog of ti_deps that will be used in the scheduler code,
# or allow batch deps checks) to ensure that the logic here is equivalent to the logic
# in the scheduler.
# Right now there's one discrepancy between this context and how scheduler schedule tasks:
# Scheduler will check if the executor has the task instance--it is not possible
# to check the executor outside scheduler main process.

# Dependencies that need to be met for a given task instance to be set to 'queued' state
# by the scheduler.
# This context has more DEPs than RUNNING_DEPS, as we can have task triggered by
# components other than scheduler, e.g. webserver.
SCHEDULER_QUEUED_DEPS = {
    RunnableExecDateDep(),
    ValidStateDep(QUEUEABLE_STATES),
    DagTISlotsAvailableDep(),
    TaskConcurrencyDep(),
    PoolSlotsAvailableDep(),
    DagrunRunningDep(),
    DagrunIdDep(),
    DagUnpausedDep(),
    ExecDateAfterStartDateDep(),
    TaskNotRunningDep(),
}
Exemple #6
0
 def test_dagrun_is_none(self):
     """
     Task instances which don't yet have an associated dagrun.
     """
     ti = Mock(get_dagrun=Mock(return_value=None))
     self.assertTrue(DagrunIdDep().is_met(ti=ti))