BaseModel
laktory.models.BaseModel
¤
Parent class for all Laktory models offering generic functions and
properties. This BaseModel
class is derived from pydantic.BaseModel
.
ATTRIBUTE | DESCRIPTION |
---|---|
variables |
Variable values to be resolved when using |
METHOD | DESCRIPTION |
---|---|
model_validate_yaml |
|
model_validate_json_file |
Load model from json file object |
push_vars |
Push variable values to all child recursively |
inject_vars |
Inject variables values into a model attributes. |
inject_vars_into_dump |
Inject variables values into a model dump. |
Functions¤
model_validate_yaml
classmethod
¤
model_validate_yaml(fp)
Load model from yaml file object. Other yaml files can be referenced
using the ${include.other_yaml_filepath} syntax. You can also merge
lists with -< ${include.other_yaml_filepath} and dictionaries with
<<: ${include.other_yaml_filepath}. Including multi-lines and
commented SQL files is also possible.
Parameters
Parameters
fp:
file object structured as a yaml file
Returns
Returns
:
Model instance
Examples:
businesses:
apple:
symbol: aapl
address: ${include.addresses.yaml}
<<: ${include.common.yaml}
emails:
- jane.doe@apple.com
-< ${include.emails.yaml}
amazon:
symbol: amzn
address: ${include.addresses.yaml}
<<: ${include.common.yaml}
emails:
- john.doe@amazon.com
-< ${include.emails.yaml}
Source code in laktory/models/basemodel.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
model_validate_json_file
classmethod
¤
model_validate_json_file(fp)
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
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
push_vars
¤
push_vars(update_core_resources=False)
Push variable values to all child recursively
Source code in laktory/models/basemodel.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
inject_vars
¤
inject_vars(inplace=False, vars=None)
Inject variables values into a model attributes.
There are 2 types of variables:
- User defined variables expressed as
${vars.variable_name}
and defined inself.variables
(pulled from stack variables) or as environment variables. Stack variables have priority over environment variables. - Resources output properties expressed as
${resources.resource_name.output}
.
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. |
Source code in laktory/models/basemodel.py
337 338 339 340 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 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
inject_vars_into_dump
¤
inject_vars_into_dump(dump, inplace=False, vars=None)
Inject variables values into a model dump.
There are 2 types of variables:
- User defined variables expressed as
${vars.variable_name}
and defined inself.variables
(pulled from stack variables) or as environment variables. Stack variables have priority over environment variables. - Resources output properties expressed as
${resources.resource_name.output}
.
PARAMETER | DESCRIPTION |
---|---|
dump
|
Model dump (or any other general purpose dictionary) |
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. |
Source code in laktory/models/basemodel.py
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 |
|