Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/airflow/executors/executor_utils.py: 38%

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

24 statements  

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.executors.executor_constants import CORE_EXECUTOR_NAMES, ConnectorSource 

20from airflow.utils.log.logging_mixin import LoggingMixin 

21 

22 

23class ExecutorName(LoggingMixin): 

24 """Representation of an executor config/name.""" 

25 

26 def __init__(self, module_path: str, alias: str | None = None, team_name: str | None = None) -> None: 

27 self.module_path: str = module_path 

28 self.alias: str | None = alias 

29 self.team_name: str | None = team_name 

30 self.set_connector_source() 

31 

32 def set_connector_source(self) -> None: 

33 if self.alias in CORE_EXECUTOR_NAMES: 

34 self.connector_source = ConnectorSource.CORE 

35 else: 

36 # Executor must be a module 

37 self.connector_source = ConnectorSource.CUSTOM_PATH 

38 

39 def __repr__(self) -> str: 

40 """Implement repr.""" 

41 if self.alias in CORE_EXECUTOR_NAMES: 

42 # This is a "core executor" we can refer to it by its known short name 

43 return f"{self.team_name if self.team_name else ''}:{self.alias}:" 

44 return f"{self.team_name if self.team_name else ''}:{self.alias if self.alias else ''}:{self.module_path}" 

45 

46 def __eq__(self, other) -> bool: 

47 """Implement eq.""" 

48 if ( 

49 self.alias == other.alias 

50 and self.module_path == other.module_path 

51 and self.connector_source == other.connector_source 

52 and self.team_name == other.team_name 

53 ): 

54 return True 

55 return False 

56 

57 def __hash__(self) -> int: 

58 """Implement hash.""" 

59 return hash(self.__repr__())