Alert
laktory.models.resources.databricks.Alert
¤
Bases: BaseModel
, PulumiResource
, TerraformResource
Databricks SQL Query
PARAMETER | DESCRIPTION |
---|---|
resource_name_
|
Name of the resource in the context of infrastructure as code. If None,
TYPE:
|
options
|
Resources options specifications
TYPE:
|
lookup_existing
|
Lookup resource instead of creating a new one.
TYPE:
|
variables
|
Dict of variables to be injected in the model at runtime |
access_controls
|
SQL Alert access controls
TYPE:
|
condition
|
Trigger conditions of the alert.
TYPE:
|
custom_body
|
Custom body of alert notification, if it exists. See Alerts API reference for custom templating instructions.
TYPE:
|
custom_subject
|
Custom subject of alert notification, if it exists. This includes email subject, Slack notification header, etc. See Alerts API reference for custom templating instructions.
TYPE:
|
dirpath
|
Workspace directory inside rootpath in which the alert is deployed. Used only if
TYPE:
|
display_name
|
Name of the alert.
TYPE:
|
name_prefix
|
Prefix added to the alert display name
TYPE:
|
name_suffix
|
Suffix added to the alert display name
TYPE:
|
notify_on_ok
|
Whether to notify alert subscribers when alert returns back to normal.
TYPE:
|
owner_user_name
|
Alert owner's username.
TYPE:
|
parent_path
|
The path to a workspace folder containing the alert. Set to
TYPE:
|
query_id
|
ID of the query evaluated by the alert. Mutually exclusive with
TYPE:
|
rootpath
|
Root directory to which all alerts are deployed to. Can also be configured by settings
LAKTORY_WORKSPACE_LAKTORY_ROOT environment variable. Default is
TYPE:
|
seconds_to_retrigger
|
Number of seconds an alert must wait after being triggered to rearm itself. After rearming, it can be triggered again. If 0 or not specified, the alert will not be triggered again.
TYPE:
|
Examples:
from laktory import models
alert = models.resources.databricks.Alert(
display_name="My Alert",
parent_path="/alerts",
query_id="1",
condition={
"op": "GREATER_THAN",
"operand": {"column": {"name": "value"}},
"threshold": {"value": {"double_value": 42.0}},
},
)
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 |
ATTRIBUTE | DESCRIPTION |
---|---|
additional_core_resources |
TYPE:
|
core_resources |
List of core resources to be deployed with this laktory model:
|
default_resource_name |
Resource default name constructed as
TYPE:
|
pulumi_properties |
Resources properties formatted for pulumi:
TYPE:
|
pulumi_renames |
Map of fields to rename when dumping model to pulumi |
resource_type_id |
Resource type id used to build default resource name. Equivalent to
TYPE:
|
self_as_core_resources |
Flag set to
|
terraform_properties |
Resources properties formatted for terraform:
TYPE:
|
terraform_renames |
Map of fields to rename when dumping model to terraform |
additional_core_resources
property
¤
- permissions
core_resources
property
¤
List of core resources to be deployed with this laktory model: - class instance (self)
default_resource_name
property
¤
Resource default name constructed as
- {self.resource_type_id}-{self.resource_key}
- removing ${resources....} tags
- removing ${vars....} tags
- Replacing special characters with - to avoid conflicts with resource properties
pulumi_properties
property
¤
Resources properties formatted for pulumi:
- Serialization (model dump)
- Removal of excludes defined in
self.pulumi_excludes
- Renaming of keys according to
self.pulumi_renames
- Injection of variables
RETURNS | DESCRIPTION |
---|---|
dict
|
Pulumi-safe model dump |
pulumi_renames
property
¤
Map of fields to rename when dumping model to pulumi
resource_type_id
property
¤
Resource type id used to build default resource name. Equivalent to class name converted to kebab case. e.g.: SecretScope -> secret-scope
self_as_core_resources
property
¤
Flag set to True
if self must be included in core resources
terraform_properties
property
¤
Resources properties formatted for terraform:
- Serialization (model dump)
- Removal of excludes defined in
self.terraform_excludes
- Renaming of keys according to
self.terraform_renames
- Injection of variables
RETURNS | DESCRIPTION |
---|---|
dict
|
Terraform-safe model dump |
terraform_renames
property
¤
Map of fields to rename when dumping model to terraform
inject_vars(inplace=False, vars=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:
|
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
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 397 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 |
|
inject_vars_into_dump(dump, inplace=False, vars=None)
¤
Inject model variables values into a model dump.
PARAMETER | DESCRIPTION |
---|---|
dump
|
Model dump (or any other general purpose mutable object) |
inplace
|
If
TYPE:
|
vars
|
A dictionary of variables to be injected in addition to the model internal variables. |
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
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 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
|
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
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
model_validate_yaml(fp)
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:
|
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
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 267 268 |
|
push_vars(update_core_resources=False)
¤
Push variable values to all child recursively
Source code in laktory/models/basemodel.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
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
323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
--
laktory.models.resources.databricks.alert.AlertCondition
¤
Bases: BaseModel
PARAMETER | DESCRIPTION |
---|---|
variables
|
Dict of variables to be injected in the model at runtime |
op
|
Operator used to compare in alert evaluation. (Enum:
TYPE:
|
operand
|
Name of the column from the query result to use for comparison in alert evaluation.
TYPE:
|
empty_result_state
|
Alert state if the result is empty (
TYPE:
|
threshold
|
Threshold value used for comparison in alert evaluation:
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)
¤
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:
|
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
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 397 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 |
|
inject_vars_into_dump(dump, inplace=False, vars=None)
¤
Inject model variables values into a model dump.
PARAMETER | DESCRIPTION |
---|---|
dump
|
Model dump (or any other general purpose mutable object) |
inplace
|
If
TYPE:
|
vars
|
A dictionary of variables to be injected in addition to the model internal variables. |
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
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 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
|
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
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
model_validate_yaml(fp)
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:
|
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
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 267 268 |
|
push_vars(update_core_resources=False)
¤
Push variable values to all child recursively
Source code in laktory/models/basemodel.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
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
323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
--
laktory.models.resources.databricks.alert.AlertConditionOperand
¤
Bases: BaseModel
PARAMETER | DESCRIPTION |
---|---|
variables
|
Dict of variables to be injected in the model at runtime |
column
|
Block describing the column from the query result to use for comparison in alert evaluation
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)
¤
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:
|
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
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 397 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 |
|
inject_vars_into_dump(dump, inplace=False, vars=None)
¤
Inject model variables values into a model dump.
PARAMETER | DESCRIPTION |
---|---|
dump
|
Model dump (or any other general purpose mutable object) |
inplace
|
If
TYPE:
|
vars
|
A dictionary of variables to be injected in addition to the model internal variables. |
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
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 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
|
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
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
model_validate_yaml(fp)
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:
|
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
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 267 268 |
|
push_vars(update_core_resources=False)
¤
Push variable values to all child recursively
Source code in laktory/models/basemodel.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
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
323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
--
laktory.models.resources.databricks.alert.AlertConditionThreshold
¤
Bases: BaseModel
PARAMETER | DESCRIPTION |
---|---|
variables
|
Dict of variables to be injected in the model at runtime |
value
|
Actual value used in comparison (one of the attributes is required)
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)
¤
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:
|
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
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 397 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 |
|
inject_vars_into_dump(dump, inplace=False, vars=None)
¤
Inject model variables values into a model dump.
PARAMETER | DESCRIPTION |
---|---|
dump
|
Model dump (or any other general purpose mutable object) |
inplace
|
If
TYPE:
|
vars
|
A dictionary of variables to be injected in addition to the model internal variables. |
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
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 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
|
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
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
model_validate_yaml(fp)
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:
|
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
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 267 268 |
|
push_vars(update_core_resources=False)
¤
Push variable values to all child recursively
Source code in laktory/models/basemodel.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
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
323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
--
laktory.models.resources.databricks.alert.AlertConditionOperandColumn
¤
Bases: BaseModel
PARAMETER | DESCRIPTION |
---|---|
variables
|
Dict of variables to be injected in the model at runtime |
name
|
Name of the column
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)
¤
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:
|
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
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 397 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 |
|
inject_vars_into_dump(dump, inplace=False, vars=None)
¤
Inject model variables values into a model dump.
PARAMETER | DESCRIPTION |
---|---|
dump
|
Model dump (or any other general purpose mutable object) |
inplace
|
If
TYPE:
|
vars
|
A dictionary of variables to be injected in addition to the model internal variables. |
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
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 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
|
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
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
model_validate_yaml(fp)
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:
|
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
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 267 268 |
|
push_vars(update_core_resources=False)
¤
Push variable values to all child recursively
Source code in laktory/models/basemodel.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
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
323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
--
laktory.models.resources.databricks.alert.AlertConditionThresholdValue
¤
Bases: BaseModel
PARAMETER | DESCRIPTION |
---|---|
variables
|
Dict of variables to be injected in the model at runtime |
bool_value
|
boolean value (
TYPE:
|
double_value
|
double value to compare against integer and double results.
TYPE:
|
string_value
|
string value to compare against string results.
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)
¤
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:
|
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
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 397 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 |
|
inject_vars_into_dump(dump, inplace=False, vars=None)
¤
Inject model variables values into a model dump.
PARAMETER | DESCRIPTION |
---|---|
dump
|
Model dump (or any other general purpose mutable object) |
inplace
|
If
TYPE:
|
vars
|
A dictionary of variables to be injected in addition to the model internal variables. |
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
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 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
|
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
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
model_validate_yaml(fp)
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:
|
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
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 267 268 |
|
push_vars(update_core_resources=False)
¤
Push variable values to all child recursively
Source code in laktory/models/basemodel.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
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
323 324 325 326 327 328 329 330 331 332 333 334 335 |
|