Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/airflow/sdk/__init__.py: 22%
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
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
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
19from typing import TYPE_CHECKING
21__all__ = [
22 "__version__",
23 "AllowedKeyMapper",
24 "Asset",
25 "AssetAccessControl",
26 "AssetAlias",
27 "AssetAll",
28 "AssetAny",
29 "AssetAndTimeSchedule",
30 "AssetOrTimeSchedule",
31 "AssetTriggeredTimetable",
32 "AssetWatcher",
33 "AsyncCallback",
34 "BaseAsyncOperator",
35 "BaseBranchOperator",
36 "BaseDeadlineReference",
37 "BaseHook",
38 "BaseNotifier",
39 "BaseOperator",
40 "BaseOperatorLink",
41 "BaseSensorOperator",
42 "BaseXCom",
43 "BranchMixIn",
44 "CallbackMeta",
45 "CallbackSource",
46 "ChainMapper",
47 "ChainRetryPolicy",
48 "Connection",
49 "Context",
50 "CronDataIntervalTimetable",
51 "CronTriggerTimetable",
52 "CronPartitionTimetable",
53 "DAG",
54 "DagRunState",
55 "DayWindow",
56 "DeadlineAlert",
57 "DeadlineReference",
58 "DeltaDataIntervalTimetable",
59 "DeltaTriggerTimetable",
60 "EdgeModifier",
61 "EventsTimetable",
62 "ExceptionRetryPolicy",
63 "FanOutMapper",
64 "FixedKeyMapper",
65 "HourWindow",
66 "IdentityMapper",
67 "Label",
68 "LoopDecision",
69 "Metadata",
70 "MinimumCount",
71 "MonthWindow",
72 "MultipleCronTriggerTimetable",
73 "NEVER_EXPIRE",
74 "ObjectStoragePath",
75 "Param",
76 "ParamsDict",
77 "PartitionedAtRuntime",
78 "PartitionedAssetTimetable",
79 "PartitionMapper",
80 "PokeReturnValue",
81 "ProductMapper",
82 "QuarterWindow",
83 "ResumableJobMixin",
84 "RetryAction",
85 "RetryDecision",
86 "RetryPolicy",
87 "RetryRule",
88 "RollupMapper",
89 "SegmentWindow",
90 "SkipMixin",
91 "SyncCallback",
92 "StartOfDayMapper",
93 "StartOfHourMapper",
94 "StartOfMonthMapper",
95 "StartOfQuarterMapper",
96 "StartOfWeekMapper",
97 "StartOfYearMapper",
98 "TaskGroup",
99 "TaskInstance",
100 "TaskInstanceState",
101 "TriggerRule",
102 "Variable",
103 "WaitForAll",
104 "WeekWindow",
105 "WeightRule",
106 "Window",
107 "XComArg",
108 "YearWindow",
109 "asset",
110 "chain",
111 "chain_linear",
112 "conf",
113 "cross_downstream",
114 "dag",
115 "deadline_reference",
116 "get_current_context",
117 "get_parsing_context",
118 "literal",
119 "lineage",
120 "macros",
121 "result",
122 "setup",
123 "task",
124 "task_group",
125 "task_handler",
126 "teardown",
127]
129__version__ = "1.5.0"
131if TYPE_CHECKING:
132 from airflow.sdk import lineage
133 from airflow.sdk.api.datamodels._generated import DagRunState, TaskInstanceState, TriggerRule, WeightRule
134 from airflow.sdk.bases.branch import BaseBranchOperator, BranchMixIn
135 from airflow.sdk.bases.hook import BaseHook
136 from airflow.sdk.bases.notifier import BaseNotifier
137 from airflow.sdk.bases.operator import (
138 BaseAsyncOperator,
139 BaseOperator,
140 chain,
141 chain_linear,
142 cross_downstream,
143 )
144 from airflow.sdk.bases.operatorlink import BaseOperatorLink
145 from airflow.sdk.bases.resumablejobmixin import ResumableJobMixin
146 from airflow.sdk.bases.sensor import BaseSensorOperator, PokeReturnValue
147 from airflow.sdk.bases.skipmixin import SkipMixin
148 from airflow.sdk.bases.xcom import BaseXCom
149 from airflow.sdk.configuration import AirflowSDKConfigParser
150 from airflow.sdk.definitions.asset import (
151 Asset,
152 AssetAccessControl,
153 AssetAlias,
154 AssetAll,
155 AssetAny,
156 AssetWatcher,
157 )
158 from airflow.sdk.definitions.asset.decorators import asset
159 from airflow.sdk.definitions.asset.metadata import Metadata
160 from airflow.sdk.definitions.callback import AsyncCallback, SyncCallback
161 from airflow.sdk.definitions.connection import Connection
162 from airflow.sdk.definitions.context import (
163 CallbackMeta as CallbackMeta,
164 CallbackSource as CallbackSource,
165 Context,
166 get_current_context,
167 get_parsing_context,
168 )
169 from airflow.sdk.definitions.dag import DAG, dag
170 from airflow.sdk.definitions.deadline import (
171 BaseDeadlineReference,
172 DeadlineAlert,
173 DeadlineReference,
174 deadline_reference,
175 )
176 from airflow.sdk.definitions.decorators import result, setup, task, teardown
177 from airflow.sdk.definitions.decorators.task_group import task_group
178 from airflow.sdk.definitions.edges import EdgeModifier, Label
179 from airflow.sdk.definitions.loop import LoopDecision
180 from airflow.sdk.definitions.param import Param, ParamsDict
181 from airflow.sdk.definitions.partition_mappers.allowed_key import AllowedKeyMapper
182 from airflow.sdk.definitions.partition_mappers.base import (
183 PartitionMapper,
184 RollupMapper,
185 )
186 from airflow.sdk.definitions.partition_mappers.chain import ChainMapper
187 from airflow.sdk.definitions.partition_mappers.fixed_key import FixedKeyMapper
188 from airflow.sdk.definitions.partition_mappers.identity import IdentityMapper
189 from airflow.sdk.definitions.partition_mappers.product import ProductMapper
190 from airflow.sdk.definitions.partition_mappers.temporal import (
191 FanOutMapper,
192 StartOfDayMapper,
193 StartOfHourMapper,
194 StartOfMonthMapper,
195 StartOfQuarterMapper,
196 StartOfWeekMapper,
197 StartOfYearMapper,
198 )
199 from airflow.sdk.definitions.partition_mappers.wait_policy import (
200 MinimumCount,
201 WaitForAll,
202 )
203 from airflow.sdk.definitions.partition_mappers.window import (
204 DayWindow,
205 HourWindow,
206 MonthWindow,
207 QuarterWindow,
208 SegmentWindow,
209 WeekWindow,
210 Window,
211 YearWindow,
212 )
213 from airflow.sdk.definitions.retry_policy import (
214 ChainRetryPolicy,
215 ExceptionRetryPolicy,
216 RetryAction,
217 RetryDecision,
218 RetryPolicy,
219 RetryRule,
220 )
221 from airflow.sdk.definitions.task_handlers.registry import task_handler
222 from airflow.sdk.definitions.taskgroup import TaskGroup
223 from airflow.sdk.definitions.template import literal
224 from airflow.sdk.definitions.timetables.assets import (
225 AssetAndTimeSchedule,
226 AssetOrTimeSchedule,
227 AssetTriggeredTimetable,
228 PartitionedAssetTimetable,
229 PartitionedAtRuntime,
230 )
231 from airflow.sdk.definitions.timetables.events import EventsTimetable
232 from airflow.sdk.definitions.timetables.interval import (
233 CronDataIntervalTimetable,
234 DeltaDataIntervalTimetable,
235 )
236 from airflow.sdk.definitions.timetables.trigger import (
237 CronPartitionTimetable,
238 CronTriggerTimetable,
239 DeltaTriggerTimetable,
240 MultipleCronTriggerTimetable,
241 )
242 from airflow.sdk.definitions.variable import Variable
243 from airflow.sdk.definitions.xcom_arg import XComArg
244 from airflow.sdk.execution_time import macros
245 from airflow.sdk.execution_time.context import NEVER_EXPIRE
246 from airflow.sdk.io.path import ObjectStoragePath
247 from airflow.sdk.types import TaskInstance
249 conf: AirflowSDKConfigParser
251# Things to lazy import in form {local_name: (target_module, target_name)}.
252# An empty target_name exposes the target module itself.
253__lazy_imports: dict[str, tuple[str, str]] = {
254 "AllowedKeyMapper": (".definitions.partition_mappers.allowed_key", "AllowedKeyMapper"),
255 "Asset": (".definitions.asset", "Asset"),
256 "AssetAccessControl": (".definitions.asset", "AssetAccessControl"),
257 "AssetAlias": (".definitions.asset", "AssetAlias"),
258 "AssetAll": (".definitions.asset", "AssetAll"),
259 "AssetAndTimeSchedule": (".definitions.timetables.assets", "AssetAndTimeSchedule"),
260 "AssetAny": (".definitions.asset", "AssetAny"),
261 "AssetOrTimeSchedule": (".definitions.timetables.assets", "AssetOrTimeSchedule"),
262 "AssetTriggeredTimetable": (".definitions.timetables.assets", "AssetTriggeredTimetable"),
263 "AssetWatcher": (".definitions.asset", "AssetWatcher"),
264 "AsyncCallback": (".definitions.callback", "AsyncCallback"),
265 "BaseAsyncOperator": (".bases.operator", "BaseAsyncOperator"),
266 "BaseBranchOperator": (".bases.branch", "BaseBranchOperator"),
267 "BaseDeadlineReference": (".definitions.deadline", "BaseDeadlineReference"),
268 "BaseHook": (".bases.hook", "BaseHook"),
269 "BaseNotifier": (".bases.notifier", "BaseNotifier"),
270 "BaseOperator": (".bases.operator", "BaseOperator"),
271 "BaseOperatorLink": (".bases.operatorlink", "BaseOperatorLink"),
272 "BaseSensorOperator": (".bases.sensor", "BaseSensorOperator"),
273 "BaseXCom": (".bases.xcom", "BaseXCom"),
274 "BranchMixIn": (".bases.branch", "BranchMixIn"),
275 "CallbackMeta": (".definitions.context", "CallbackMeta"),
276 "CallbackSource": (".definitions.context", "CallbackSource"),
277 "ChainMapper": (".definitions.partition_mappers.chain", "ChainMapper"),
278 "ChainRetryPolicy": (".definitions.retry_policy", "ChainRetryPolicy"),
279 "Connection": (".definitions.connection", "Connection"),
280 "Context": (".definitions.context", "Context"),
281 "CronDataIntervalTimetable": (".definitions.timetables.interval", "CronDataIntervalTimetable"),
282 "CronTriggerTimetable": (".definitions.timetables.trigger", "CronTriggerTimetable"),
283 "CronPartitionTimetable": (".definitions.timetables.trigger", "CronPartitionTimetable"),
284 "DAG": (".definitions.dag", "DAG"),
285 "DagRunState": (".api.datamodels._generated", "DagRunState"),
286 "DayWindow": (".definitions.partition_mappers.window", "DayWindow"),
287 "DeadlineAlert": (".definitions.deadline", "DeadlineAlert"),
288 "DeadlineReference": (".definitions.deadline", "DeadlineReference"),
289 "DeltaDataIntervalTimetable": (".definitions.timetables.interval", "DeltaDataIntervalTimetable"),
290 "DeltaTriggerTimetable": (".definitions.timetables.trigger", "DeltaTriggerTimetable"),
291 "EdgeModifier": (".definitions.edges", "EdgeModifier"),
292 "EventsTimetable": (".definitions.timetables.events", "EventsTimetable"),
293 "ExceptionRetryPolicy": (".definitions.retry_policy", "ExceptionRetryPolicy"),
294 "FanOutMapper": (".definitions.partition_mappers.temporal", "FanOutMapper"),
295 "FixedKeyMapper": (".definitions.partition_mappers.fixed_key", "FixedKeyMapper"),
296 "HourWindow": (".definitions.partition_mappers.window", "HourWindow"),
297 "IdentityMapper": (".definitions.partition_mappers.identity", "IdentityMapper"),
298 "Label": (".definitions.edges", "Label"),
299 "LoopDecision": (".definitions.loop", "LoopDecision"),
300 "Metadata": (".definitions.asset.metadata", "Metadata"),
301 "MinimumCount": (".definitions.partition_mappers.wait_policy", "MinimumCount"),
302 "MonthWindow": (".definitions.partition_mappers.window", "MonthWindow"),
303 "MultipleCronTriggerTimetable": (".definitions.timetables.trigger", "MultipleCronTriggerTimetable"),
304 "ObjectStoragePath": (".io.path", "ObjectStoragePath"),
305 "Param": (".definitions.param", "Param"),
306 "ParamsDict": (".definitions.param", "ParamsDict"),
307 "PartitionedAtRuntime": (".definitions.timetables.assets", "PartitionedAtRuntime"),
308 "PartitionedAssetTimetable": (".definitions.timetables.assets", "PartitionedAssetTimetable"),
309 "PartitionMapper": (".definitions.partition_mappers.base", "PartitionMapper"),
310 "PokeReturnValue": (".bases.sensor", "PokeReturnValue"),
311 "ProductMapper": (".definitions.partition_mappers.product", "ProductMapper"),
312 "QuarterWindow": (".definitions.partition_mappers.window", "QuarterWindow"),
313 "ResumableJobMixin": (".bases.resumablejobmixin", "ResumableJobMixin"),
314 "RetryAction": (".definitions.retry_policy", "RetryAction"),
315 "RetryDecision": (".definitions.retry_policy", "RetryDecision"),
316 "RetryPolicy": (".definitions.retry_policy", "RetryPolicy"),
317 "RetryRule": (".definitions.retry_policy", "RetryRule"),
318 "RollupMapper": (".definitions.partition_mappers.base", "RollupMapper"),
319 "SecretCache": (".execution_time.cache", "SecretCache"),
320 "SegmentWindow": (".definitions.partition_mappers.window", "SegmentWindow"),
321 "SkipMixin": (".bases.skipmixin", "SkipMixin"),
322 "SyncCallback": (".definitions.callback", "SyncCallback"),
323 "StartOfDayMapper": (".definitions.partition_mappers.temporal", "StartOfDayMapper"),
324 "StartOfHourMapper": (".definitions.partition_mappers.temporal", "StartOfHourMapper"),
325 "StartOfMonthMapper": (".definitions.partition_mappers.temporal", "StartOfMonthMapper"),
326 "StartOfQuarterMapper": (".definitions.partition_mappers.temporal", "StartOfQuarterMapper"),
327 "StartOfWeekMapper": (".definitions.partition_mappers.temporal", "StartOfWeekMapper"),
328 "StartOfYearMapper": (".definitions.partition_mappers.temporal", "StartOfYearMapper"),
329 "TaskGroup": (".definitions.taskgroup", "TaskGroup"),
330 "TaskInstance": (".types", "TaskInstance"),
331 "TaskInstanceState": (".api.datamodels._generated", "TaskInstanceState"),
332 "TriggerRule": (".api.datamodels._generated", "TriggerRule"),
333 "Variable": (".definitions.variable", "Variable"),
334 "WaitForAll": (".definitions.partition_mappers.wait_policy", "WaitForAll"),
335 "WeekWindow": (".definitions.partition_mappers.window", "WeekWindow"),
336 "WeightRule": (".api.datamodels._generated", "WeightRule"),
337 "Window": (".definitions.partition_mappers.window", "Window"),
338 "XComArg": (".definitions.xcom_arg", "XComArg"),
339 "YearWindow": (".definitions.partition_mappers.window", "YearWindow"),
340 "asset": (".definitions.asset.decorators", "asset"),
341 "chain": (".bases.operator", "chain"),
342 "chain_linear": (".bases.operator", "chain_linear"),
343 "conf": (".configuration", "conf"),
344 "cross_downstream": (".bases.operator", "cross_downstream"),
345 "dag": (".definitions.dag", "dag"),
346 "deadline_reference": (".definitions.deadline", "deadline_reference"),
347 "NEVER_EXPIRE": (".execution_time.context", "NEVER_EXPIRE"),
348 "get_current_context": (".definitions.context", "get_current_context"),
349 "get_parsing_context": (".definitions.context", "get_parsing_context"),
350 "literal": (".definitions.template", "literal"),
351 "lineage": (".lineage", ""),
352 "macros": (".execution_time.macros", ""),
353 "result": (".definitions.decorators", "result"),
354 "setup": (".definitions.decorators", "setup"),
355 "task": (".definitions.decorators", "task"),
356 "task_group": (".definitions.decorators", "task_group"),
357 "task_handler": (".definitions.task_handlers.registry", "task_handler"),
358 "teardown": (".definitions.decorators", "teardown"),
359}
362def __getattr__(name: str):
363 module_path, attr_name = __lazy_imports.get(name, ("", ""))
364 if not module_path:
365 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
367 import importlib
369 mod = importlib.import_module(module_path, __name__)
370 val = getattr(mod, attr_name) if attr_name else mod
372 # Store for next time
373 globals()[name] = val
374 return val