Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/airflow/sdk/__init__.py: 23%

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

56 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 typing import TYPE_CHECKING 

20 

21__all__ = [ 

22 "__version__", 

23 "AllowedKeyMapper", 

24 "Asset", 

25 "AssetAlias", 

26 "AssetAll", 

27 "AssetAny", 

28 "AssetOrTimeSchedule", 

29 "AssetWatcher", 

30 "AsyncCallback", 

31 "BaseAsyncOperator", 

32 "BaseBranchOperator", 

33 "BaseHook", 

34 "BaseNotifier", 

35 "BaseOperator", 

36 "BaseOperatorLink", 

37 "BaseSensorOperator", 

38 "BaseXCom", 

39 "BranchMixIn", 

40 "ChainMapper", 

41 "Connection", 

42 "Context", 

43 "CronDataIntervalTimetable", 

44 "CronTriggerTimetable", 

45 "CronPartitionTimetable", 

46 "DAG", 

47 "DagRunState", 

48 "DeadlineAlert", 

49 "DeadlineReference", 

50 "DeltaDataIntervalTimetable", 

51 "DeltaTriggerTimetable", 

52 "EdgeModifier", 

53 "EventsTimetable", 

54 "ExceptionRetryPolicy", 

55 "IdentityMapper", 

56 "Label", 

57 "Metadata", 

58 "MultipleCronTriggerTimetable", 

59 "ObjectStoragePath", 

60 "Param", 

61 "ParamsDict", 

62 "PartitionedAssetTimetable", 

63 "PartitionMapper", 

64 "PokeReturnValue", 

65 "ProductMapper", 

66 "RetryAction", 

67 "RetryDecision", 

68 "RetryPolicy", 

69 "RetryRule", 

70 "SkipMixin", 

71 "SyncCallback", 

72 "StartOfDayMapper", 

73 "StartOfHourMapper", 

74 "StartOfMonthMapper", 

75 "StartOfQuarterMapper", 

76 "StartOfWeekMapper", 

77 "StartOfYearMapper", 

78 "TaskGroup", 

79 "TaskInstance", 

80 "TaskInstanceState", 

81 "TriggerRule", 

82 "Variable", 

83 "WeightRule", 

84 "XComArg", 

85 "asset", 

86 "chain", 

87 "chain_linear", 

88 "conf", 

89 "cross_downstream", 

90 "dag", 

91 "get_current_context", 

92 "get_parsing_context", 

93 "literal", 

94 "lineage", 

95 "macros", 

96 "setup", 

97 "task", 

98 "task_group", 

99 "teardown", 

100] 

101 

102__version__ = "1.3.0" 

103 

104if TYPE_CHECKING: 

105 from airflow.sdk.api.datamodels._generated import DagRunState, TaskInstanceState, TriggerRule, WeightRule 

106 from airflow.sdk.bases.branch import BaseBranchOperator, BranchMixIn 

107 from airflow.sdk.bases.hook import BaseHook 

108 from airflow.sdk.bases.notifier import BaseNotifier 

109 from airflow.sdk.bases.operator import ( 

110 BaseAsyncOperator, 

111 BaseOperator, 

112 chain, 

113 chain_linear, 

114 cross_downstream, 

115 ) 

116 from airflow.sdk.bases.operatorlink import BaseOperatorLink 

117 from airflow.sdk.bases.sensor import BaseSensorOperator, PokeReturnValue 

118 from airflow.sdk.bases.skipmixin import SkipMixin 

119 from airflow.sdk.bases.xcom import BaseXCom 

120 from airflow.sdk.configuration import AirflowSDKConfigParser 

121 from airflow.sdk.definitions.asset import Asset, AssetAlias, AssetAll, AssetAny, AssetWatcher 

122 from airflow.sdk.definitions.asset.decorators import asset 

123 from airflow.sdk.definitions.asset.metadata import Metadata 

124 from airflow.sdk.definitions.callback import AsyncCallback, SyncCallback 

125 from airflow.sdk.definitions.connection import Connection 

126 from airflow.sdk.definitions.context import Context, get_current_context, get_parsing_context 

127 from airflow.sdk.definitions.dag import DAG, dag 

128 from airflow.sdk.definitions.deadline import DeadlineAlert, DeadlineReference 

129 from airflow.sdk.definitions.decorators import setup, task, teardown 

130 from airflow.sdk.definitions.decorators.task_group import task_group 

131 from airflow.sdk.definitions.edges import EdgeModifier, Label 

132 from airflow.sdk.definitions.param import Param, ParamsDict 

133 from airflow.sdk.definitions.partition_mappers.allowed_key import AllowedKeyMapper 

134 from airflow.sdk.definitions.partition_mappers.base import PartitionMapper 

135 from airflow.sdk.definitions.partition_mappers.chain import ChainMapper 

136 from airflow.sdk.definitions.partition_mappers.identity import IdentityMapper 

137 from airflow.sdk.definitions.partition_mappers.product import ProductMapper 

138 from airflow.sdk.definitions.partition_mappers.temporal import ( 

139 StartOfDayMapper, 

140 StartOfHourMapper, 

141 StartOfMonthMapper, 

142 StartOfQuarterMapper, 

143 StartOfWeekMapper, 

144 StartOfYearMapper, 

145 ) 

146 from airflow.sdk.definitions.retry_policy import ( 

147 ExceptionRetryPolicy, 

148 RetryAction, 

149 RetryDecision, 

150 RetryPolicy, 

151 RetryRule, 

152 ) 

153 from airflow.sdk.definitions.taskgroup import TaskGroup 

154 from airflow.sdk.definitions.template import literal 

155 from airflow.sdk.definitions.timetables.assets import ( 

156 AssetOrTimeSchedule, 

157 PartitionedAssetTimetable, 

158 ) 

159 from airflow.sdk.definitions.timetables.events import EventsTimetable 

160 from airflow.sdk.definitions.timetables.interval import ( 

161 CronDataIntervalTimetable, 

162 DeltaDataIntervalTimetable, 

163 ) 

164 from airflow.sdk.definitions.timetables.trigger import ( 

165 CronPartitionTimetable, 

166 CronTriggerTimetable, 

167 DeltaTriggerTimetable, 

168 MultipleCronTriggerTimetable, 

169 ) 

170 from airflow.sdk.definitions.variable import Variable 

171 from airflow.sdk.definitions.xcom_arg import XComArg 

172 from airflow.sdk.execution_time import macros 

173 from airflow.sdk.io.path import ObjectStoragePath 

174 from airflow.sdk.types import TaskInstance 

175 

176 conf: AirflowSDKConfigParser 

177 

178__lazy_imports: dict[str, str] = { 

179 "AllowedKeyMapper": ".definitions.partition_mappers.allowed_key", 

180 "Asset": ".definitions.asset", 

181 "AssetAlias": ".definitions.asset", 

182 "AssetAll": ".definitions.asset", 

183 "AssetAny": ".definitions.asset", 

184 "AssetOrTimeSchedule": ".definitions.timetables.assets", 

185 "AssetWatcher": ".definitions.asset", 

186 "AsyncCallback": ".definitions.callback", 

187 "BaseAsyncOperator": ".bases.operator", 

188 "BaseBranchOperator": ".bases.branch", 

189 "BaseHook": ".bases.hook", 

190 "BaseNotifier": ".bases.notifier", 

191 "BaseOperator": ".bases.operator", 

192 "BaseOperatorLink": ".bases.operatorlink", 

193 "BaseSensorOperator": ".bases.sensor", 

194 "BaseXCom": ".bases.xcom", 

195 "BranchMixIn": ".bases.branch", 

196 "ChainMapper": ".definitions.partition_mappers.chain", 

197 "Connection": ".definitions.connection", 

198 "Context": ".definitions.context", 

199 "CronDataIntervalTimetable": ".definitions.timetables.interval", 

200 "CronTriggerTimetable": ".definitions.timetables.trigger", 

201 "CronPartitionTimetable": ".definitions.timetables.trigger", 

202 "DAG": ".definitions.dag", 

203 "DagRunState": ".api.datamodels._generated", 

204 "DeadlineAlert": ".definitions.deadline", 

205 "DeadlineReference": ".definitions.deadline", 

206 "DeltaDataIntervalTimetable": ".definitions.timetables.interval", 

207 "DeltaTriggerTimetable": ".definitions.timetables.trigger", 

208 "EdgeModifier": ".definitions.edges", 

209 "EventsTimetable": ".definitions.timetables.events", 

210 "ExceptionRetryPolicy": ".definitions.retry_policy", 

211 "IdentityMapper": ".definitions.partition_mappers.identity", 

212 "Label": ".definitions.edges", 

213 "Metadata": ".definitions.asset.metadata", 

214 "MultipleCronTriggerTimetable": ".definitions.timetables.trigger", 

215 "ObjectStoragePath": ".io.path", 

216 "Param": ".definitions.param", 

217 "ParamsDict": ".definitions.param", 

218 "PartitionedAssetTimetable": ".definitions.timetables.assets", 

219 "PartitionMapper": ".definitions.partition_mappers.base", 

220 "PokeReturnValue": ".bases.sensor", 

221 "ProductMapper": ".definitions.partition_mappers.product", 

222 "RetryAction": ".definitions.retry_policy", 

223 "RetryDecision": ".definitions.retry_policy", 

224 "RetryPolicy": ".definitions.retry_policy", 

225 "RetryRule": ".definitions.retry_policy", 

226 "SecretCache": ".execution_time.cache", 

227 "SkipMixin": ".bases.skipmixin", 

228 "SyncCallback": ".definitions.callback", 

229 "StartOfDayMapper": ".definitions.partition_mappers.temporal", 

230 "StartOfHourMapper": ".definitions.partition_mappers.temporal", 

231 "StartOfMonthMapper": ".definitions.partition_mappers.temporal", 

232 "StartOfQuarterMapper": ".definitions.partition_mappers.temporal", 

233 "StartOfWeekMapper": ".definitions.partition_mappers.temporal", 

234 "StartOfYearMapper": ".definitions.partition_mappers.temporal", 

235 "TaskGroup": ".definitions.taskgroup", 

236 "TaskInstance": ".types", 

237 "TaskInstanceState": ".api.datamodels._generated", 

238 "TriggerRule": ".api.datamodels._generated", 

239 "Variable": ".definitions.variable", 

240 "WeightRule": ".api.datamodels._generated", 

241 "XComArg": ".definitions.xcom_arg", 

242 "asset": ".definitions.asset.decorators", 

243 "chain": ".bases.operator", 

244 "chain_linear": ".bases.operator", 

245 "conf": ".configuration", 

246 "cross_downstream": ".bases.operator", 

247 "dag": ".definitions.dag", 

248 "get_current_context": ".definitions.context", 

249 "get_parsing_context": ".definitions.context", 

250 "literal": ".definitions.template", 

251 "lineage": ".lineage", 

252 "macros": ".execution_time", 

253 "setup": ".definitions.decorators", 

254 "task": ".definitions.decorators", 

255 "task_group": ".definitions.decorators", 

256 "teardown": ".definitions.decorators", 

257} 

258 

259 

260def __getattr__(name: str): 

261 if module_path := __lazy_imports.get(name): 

262 import importlib 

263 

264 mod = importlib.import_module(module_path, __name__) 

265 val = getattr(mod, name) 

266 

267 # Store for next time 

268 globals()[name] = val 

269 return val 

270 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")