tsdat.config.utils
¶
Classes¶
Functions¶
Recursively calls model.instantiate() on all ParameterizedConfigClass instances under |
Function Descriptions
-
class
tsdat.config.utils.
ParameterizedConfigClass
[source]¶ Bases:
pydantic.BaseModel
Class Methods
Instantiates and returns the class specified by the ‘classname’ parameter.
Method Descriptions
-
class
tsdat.config.utils.
YamlModel
[source]¶ Bases:
pydantic.BaseModel
Class Methods
Method Descriptions
-
tsdat.config.utils.
recursive_instantiate
(model: Any) → Any[source]¶ Recursively calls model.instantiate() on all ParameterizedConfigClass instances under the the model, resulting in a new model which follows the same general structure as the given model, but possibly containing totally different properties and methods.
Note that this method does a depth-first traversal of the model tree to to instantiate leaf nodes first. Traversing breadth-first would result in new pydantic models attempting to call the __init__ method of child models, which is not valid because the child models are ParameterizedConfigClass instances. Traversing depth-first allows us to first transform child models into the appropriate type using the classname of the ParameterizedConfigClass.
This method is primarily used to instantiate a Pipeline subclass and all of its properties from a yaml pipeline config file, but it can be applied to any other pydantic model.
- Parameters
model (Any) – The object to recursively instantiate.
- Returns
The recursively-instantiated object.
- Return type
Any