def test_ti_not_running(self): """ Non-running task instances should pass this dep """ ti = FakeTI(state=State.NONE, start_date=datetime(2016, 1, 1)) self.assertTrue(NotRunningDep().is_met(ti=ti, dep_context=None))
def test_ti_running(self): """ Running task instances should fail this dep """ ti = FakeTI(state=State.RUNNING, start_date=datetime(2016, 1, 1)) self.assertFalse(NotRunningDep().is_met(ti=ti, dep_context=None))
# In order to be able to get queued a task must have one of these states QUEUEABLE_STATES = { State.FAILED, State.NONE, State.QUEUED, State.SCHEDULED, State.SKIPPED, State.UPSTREAM_FAILED, State.UP_FOR_RETRY, State.UP_FOR_RESCHEDULE, } # Context to get the dependencies that need to be met in order for a task instance to # be backfilled. QUEUE_DEPS = { NotRunningDep(), NotSkippedDep(), RunnableExecDateDep(), ValidStateDep(QUEUEABLE_STATES), } # Dependencies that need to be met for a given task instance to be able to get run by an # executor. This class just extends QueueContext by adding dependencies for resources. RUN_DEPS = QUEUE_DEPS | { DagTISlotsAvailableDep(), TaskConcurrencyDep(), } # TODO(aoen): SCHEDULER_DEPS is not coupled to actual 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
# In order to be able to get queued a task must have one of these states QUEUEABLE_STATES = { State.FAILED, State.NONE, State.QUEUED, State.SCHEDULED, State.SKIPPED, State.UPSTREAM_FAILED, State.UP_FOR_RETRY, } # Context to get the dependencies that need to be met in order for a task instance to # be backfilled. QUEUE_DEPS = { NotRunningDep(), # 任务实例没有运行 NotSkippedDep(), # 任务实例没有被标记为跳过 RunnableExecDateDep(), # 判断任务执行时间 必须小于等于当前时间 且 小于等于结束时间 ValidStateDep(QUEUEABLE_STATES), # 验证任务的状态必须在队列状态中 } # Dependencies that need to be met for a given task instance to be able to get run by an # executor. This class just extends QueueContext by adding dependencies for resources. RUN_DEPS = QUEUE_DEPS | { DagTISlotsAvailableDep(), # 每个dag能并发执行的最大任务数依赖 TaskConcurrencyDep(), # 每个任务的任务实例有最大限制 } # TODO(aoen): SCHEDULER_DEPS is not coupled to actual 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