Coverage for /pythoncovmergedfiles/medio/medio/src/airflow/build/lib/airflow/ti_deps/dependencies_deps.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:35 +0000

1# Licensed to the Apache Software Foundation (ASF) under one 

2# or more contributor license agreements. See the NOTICE file 

3# distributed with this work for additional information 

4# regarding copyright ownership. The ASF licenses this file 

5# to you under the Apache License, Version 2.0 (the 

6# "License"); you may not use this file except in compliance 

7# with the License. You may obtain a copy of the License at 

8# 

9# http://www.apache.org/licenses/LICENSE-2.0 

10# 

11# Unless required by applicable law or agreed to in writing, 

12# software distributed under the License is distributed on an 

13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 

14# KIND, either express or implied. See the License for the 

15# specific language governing permissions and limitations 

16# under the License. 

17from __future__ import annotations 

18 

19from airflow.ti_deps.dependencies_states import ( 

20 BACKFILL_QUEUEABLE_STATES, 

21 QUEUEABLE_STATES, 

22 RUNNABLE_STATES, 

23 SCHEDULEABLE_STATES, 

24) 

25from airflow.ti_deps.deps.dag_ti_slots_available_dep import DagTISlotsAvailableDep 

26from airflow.ti_deps.deps.dag_unpaused_dep import DagUnpausedDep 

27from airflow.ti_deps.deps.dagrun_backfill_dep import DagRunNotBackfillDep 

28from airflow.ti_deps.deps.dagrun_exists_dep import DagrunRunningDep 

29from airflow.ti_deps.deps.exec_date_after_start_date_dep import ExecDateAfterStartDateDep 

30from airflow.ti_deps.deps.pool_slots_available_dep import PoolSlotsAvailableDep 

31from airflow.ti_deps.deps.runnable_exec_date_dep import RunnableExecDateDep 

32from airflow.ti_deps.deps.task_concurrency_dep import TaskConcurrencyDep 

33from airflow.ti_deps.deps.task_not_running_dep import TaskNotRunningDep 

34from airflow.ti_deps.deps.valid_state_dep import ValidStateDep 

35 

36# Context to get the dependencies that need to be met in order for a task instance to be 

37# set to 'scheduled' state. 

38SCHEDULED_DEPS = { 

39 RunnableExecDateDep(), 

40 ValidStateDep(SCHEDULEABLE_STATES), 

41 TaskNotRunningDep(), 

42} 

43 

44# Dependencies that if met, task instance should be re-queued. 

45REQUEUEABLE_DEPS = { 

46 DagTISlotsAvailableDep(), 

47 TaskConcurrencyDep(), 

48 PoolSlotsAvailableDep(), 

49} 

50 

51# Dependencies that need to be met for a given task instance to be set to 'RUNNING' state. 

52RUNNING_DEPS = { 

53 RunnableExecDateDep(), 

54 ValidStateDep(RUNNABLE_STATES), 

55 DagTISlotsAvailableDep(), 

56 TaskConcurrencyDep(), 

57 PoolSlotsAvailableDep(), 

58 TaskNotRunningDep(), 

59} 

60 

61BACKFILL_QUEUED_DEPS = { 

62 RunnableExecDateDep(), 

63 ValidStateDep(BACKFILL_QUEUEABLE_STATES), 

64 DagrunRunningDep(), 

65 TaskNotRunningDep(), 

66} 

67 

68# TODO(aoen): SCHEDULER_QUEUED_DEPS is not coupled to actual scheduling/execution 

69# in any way and could easily be modified or removed from the scheduler causing 

70# this dependency to become outdated and incorrect. This coupling should be created 

71# (e.g. via a dag_deps analog of ti_deps that will be used in the scheduler code, 

72# or allow batch deps checks) to ensure that the logic here is equivalent to the logic 

73# in the scheduler. 

74# Right now there's one discrepancy between this context and how scheduler schedule tasks: 

75# Scheduler will check if the executor has the task instance--it is not possible 

76# to check the executor outside scheduler main process. 

77 

78# Dependencies that need to be met for a given task instance to be set to 'queued' state 

79# by the scheduler. 

80# This context has more DEPs than RUNNING_DEPS, as we can have task triggered by 

81# components other than scheduler, e.g. webserver. 

82SCHEDULER_QUEUED_DEPS = { 

83 RunnableExecDateDep(), 

84 ValidStateDep(QUEUEABLE_STATES), 

85 DagTISlotsAvailableDep(), 

86 TaskConcurrencyDep(), 

87 PoolSlotsAvailableDep(), 

88 DagrunRunningDep(), 

89 DagRunNotBackfillDep(), 

90 DagUnpausedDep(), 

91 ExecDateAfterStartDateDep(), 

92 TaskNotRunningDep(), 

93}