Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/airflow/ti_deps/deps/task_not_running_dep.py: 72%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

18 statements  

1# 

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

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

4# distributed with this work for additional information 

5# regarding copyright ownership. The ASF licenses this file 

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

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

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

9# 

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

11# 

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

13# software distributed under the License is distributed on an 

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

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

16# specific language governing permissions and limitations 

17# under the License. 

18"""Contains the TaskNotRunningDep.""" 

19 

20from __future__ import annotations 

21 

22from airflow.ti_deps.deps.base_ti_dep import BaseTIDep 

23from airflow.utils.session import provide_session 

24from airflow.utils.state import TaskInstanceState 

25 

26 

27class TaskNotRunningDep(BaseTIDep): 

28 """Ensures that the task instance's state is not running.""" 

29 

30 NAME = "Task Instance Not Running" 

31 IGNORABLE = False 

32 

33 def __eq__(self, other): 

34 """Check if two task instance dependencies are of the same type.""" 

35 return type(self) == type(other) 

36 

37 def __hash__(self): 

38 """Compute the hash value based on the type of the task instance dependency.""" 

39 return hash(type(self)) 

40 

41 @provide_session 

42 def _get_dep_statuses(self, ti, session, dep_context=None): 

43 if ti.state != TaskInstanceState.RUNNING: 

44 yield self._passing_status(reason="Task is not in running state.") 

45 return 

46 

47 yield self._failing_status(reason="Task is in the running state")