Airflow
laktory.models.pipeline.AirflowOrchestrator
¤
Bases: PipelineChild
Airflow used as an orchestrator to execute a Laktory pipeline.
Examples:
import laktory as lk
o = lk.models.AirflowOrchestrator(
description="A Laktory pipeline",
schedule={
"cron": "0 0 * * *",
"timezone": "utc",
},
start_date="2026-03-03",
max_active_runs=1,
)
print(o)
'''
dataframe_backend_=None dataframe_api_=None type='AIRFLOW' description='A Laktory pipeline' schedule=CronSchedule(variables={}, cron='0 0 * * *', timezone='utc') start_date=datetime.datetime(2026, 3, 3, 0, 0, tzinfo=datetime.timezone.utc) end_date=None template_searchpath=None user_defined_macros=None user_defined_filters=None default_args=None max_active_tasks=None max_active_runs=1 max_consecutive_failed_dag_runs=None dagrun_timeout=None catchup=None doc_md=None access_control=None is_paused_upon_creation=None jinja_environment_kwargs=None render_template_as_native_obj=None tags=None owner_links=None auto_register=None fail_fast=None dag_display_name=None disable_bundle_versioning=None dataframe_backend=<DataFrameBackends.PYSPARK: 'PYSPARK'> dataframe_api='NARWHALS'
'''
References
| PARAMETER | DESCRIPTION |
|---|---|
dataframe_backend_
|
Type of DataFrame backend
TYPE:
|
dataframe_api_
|
DataFrame API to use in DataFrame Transformer nodes. Either 'NATIVE' (backend-specific) or 'NARWHALS' (backend-agnostic).
TYPE:
|
type
|
Type of orchestrator
TYPE:
|
description
|
Optional human-readable description of the DAG.
TYPE:
|
schedule
|
Schedule that defines when the DAG should run. Uses a cron expression and timezone.
TYPE:
|
start_date
|
The earliest date from which the scheduler will start creating DAG runs.
TYPE:
|
end_date
|
Optional date after which no new DAG runs will be scheduled.
TYPE:
|
template_searchpath
|
Directories to search for template files referenced in templated fields.
TYPE:
|
user_defined_macros
|
Custom macros made available in the Jinja template context for all tasks in the DAG.
TYPE:
|
user_defined_filters
|
Custom Jinja filters available when rendering templated fields.
TYPE:
|
default_args
|
Dictionary of default arguments applied to all tasks in the DAG unless overridden.
TYPE:
|
max_active_tasks
|
Maximum number of task instances allowed to run concurrently across all DAG runs.
TYPE:
|
max_active_runs
|
Maximum number of active DAG runs allowed at the same time.
TYPE:
|
max_consecutive_failed_dag_runs
|
Number of consecutive failed DAG runs allowed before the DAG is automatically paused.
TYPE:
|
dagrun_timeout
|
Maximum time allowed for a DAG run to complete before it is marked as failed.
TYPE:
|
catchup
|
Whether the scheduler should create DAG runs for all past schedule intervals between the start date and the current time.
TYPE:
|
doc_md
|
Markdown documentation displayed in the Airflow UI for the DAG.
TYPE:
|
access_control
|
Access control configuration defining roles and permissions for this DAG.
TYPE:
|
is_paused_upon_creation
|
Whether the DAG should be paused when first created.
TYPE:
|
jinja_environment_kwargs
|
Additional keyword arguments used when creating the Jinja template environment.
TYPE:
|
render_template_as_native_obj
|
If true, Jinja templates will render native Python objects instead of strings.
TYPE:
|
tags
|
Tags used to organize and filter DAGs in the Airflow UI.
TYPE:
|
owner_links
|
Mapping of DAG owners to URLs that provide additional information about them.
TYPE:
|
auto_register
|
Whether the DAG should automatically be registered when parsed by Airflow.
TYPE:
|
fail_fast
|
If enabled, the DAG run will stop scheduling new tasks as soon as a task fails.
TYPE:
|
dag_display_name
|
Human-friendly name displayed in the Airflow UI instead of the DAG ID.
TYPE:
|
disable_bundle_versioning
|
If enabled, disables versioning of DAG bundles when deploying.
TYPE:
|
--
laktory.models.pipeline.orchestrators.airfloworchestrator.CronSchedule
¤
Bases: BaseModel
Cron Schedule.
| PARAMETER | DESCRIPTION |
|---|---|
variables
|
Dict of variables to be injected in the model at runtime
TYPE:
|
cron
|
Cron expression defining when the DAG should be scheduled to run.
TYPE:
|
timezone
|
Timezone used to interpret the cron schedule.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
inject_vars |
Inject model variables values into a model attributes. |
inject_vars_into_dump |
Inject model variables values into a model dump. |
model_validate_json_file |
Load model from json file object |
model_validate_yaml |
Load model from yaml file object using laktory.yaml.RecursiveLoader. Supports |
push_vars |
Push variable values to all child recursively |
validate_assignment_disabled |
Updating a model attribute inside a model validator when |
inject_vars(inplace=False, vars=None, objs=None)
¤
Inject model variables values into a model attributes.
| PARAMETER | DESCRIPTION |
|---|---|
inplace
|
If
TYPE:
|
vars
|
A dictionary of variables to be injected in addition to the model internal variables.
TYPE:
|
objs
|
A dictionary of objects available when resolving expressions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
|
Model instance. |
Examples:
from typing import Union
from laktory import models
class Cluster(models.BaseModel):
name: str = None
size: Union[int, str] = None
c = Cluster(
name="cluster-${vars.my_cluster}",
size="${{ 4 if vars.env == 'prod' else 2 }}",
variables={
"env": "dev",
},
).inject_vars()
print(c)
# > variables={'env': 'dev'} name='cluster-${vars.my_cluster}' size=2
References
Source code in laktory/models/basemodel.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | |
inject_vars_into_dump(dump, inplace=False, vars=None, objs=None)
¤
Inject model variables values into a model dump.
| PARAMETER | DESCRIPTION |
|---|---|
dump
|
Model dump (or any other general purpose mutable object)
TYPE:
|
inplace
|
If
TYPE:
|
vars
|
A dictionary of variables to be injected in addition to the model internal variables.
TYPE:
|
objs
|
A dictionary of objects available when resolving expressions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
|
Model dump with injected variables. |
Examples:
from laktory import models
m = models.BaseModel(
variables={
"env": "dev",
},
)
data = {
"name": "cluster-${vars.my_cluster}",
"size": "${{ 4 if vars.env == 'prod' else 2 }}",
}
print(m.inject_vars_into_dump(data))
# > {'name': 'cluster-${vars.my_cluster}', 'size': 2}
References
Source code in laktory/models/basemodel.py
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | |
model_validate_json_file(fp)
classmethod
¤
Load model from json file object
| PARAMETER | DESCRIPTION |
|---|---|
fp
|
file object structured as a json file
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Model
|
Model instance |
Source code in laktory/models/basemodel.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
model_validate_yaml(fp, vars=None)
classmethod
¤
Load model from yaml file object using laktory.yaml.RecursiveLoader. Supports
reference to external yaml and sql files using !use, !extend and !update tags.
Path to external files can be defined using model or environment variables.
Referenced path should always be relative to the file they are referenced from.
| PARAMETER | DESCRIPTION |
|---|---|
fp
|
file object structured as a yaml file
TYPE:
|
vars
|
Dict of variables available when parsing filepaths references in yaml files
i.e.
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
Model
|
Model instance |
Examples:
businesses:
apple:
symbol: aapl
address: !use addresses.yaml
<<: !update common.yaml
emails:
- jane.doe@apple.com
- extend! emails.yaml
amazon:
symbol: amzn
address: !use addresses.yaml
<<: update! common.yaml
emails:
- john.doe@amazon.com
- extend! emails.yaml
Source code in laktory/models/basemodel.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
push_vars(update_core_resources=False)
¤
Push variable values to all child recursively
Source code in laktory/models/basemodel.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
validate_assignment_disabled()
¤
Updating a model attribute inside a model validator when validate_assignment
is True causes an infinite recursion by design and must be turned off
temporarily.
Source code in laktory/models/basemodel.py
350 351 352 353 354 355 356 357 358 359 360 361 362 | |