ConfigLoader
Reference for the ConfigLoader
class, which contains the logic used for parsing a pipeline configuration file into a format that can be understood by the Runner
.
aineko.ConfigLoader
ConfigLoader(pipeline_config_file: str)
Class to read yaml config files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline_config_file |
str
|
path of pipeline config file. Defaults
to |
required |
Attributes:
Name | Type | Description |
---|---|---|
pipeline_config_file |
str
|
path to the pipeline configuration file |
Methods:
Name | Description |
---|---|
load_config |
loads and validates the pipeline config from a yaml file |
inject_env_vars |
injects environment variables into node params |
Initialize ConfigLoader.
Source code in aineko/core/config_loader.py
33 34 35 36 37 38 39 40 |
|
pipeline_config_file
instance-attribute
pipeline_config_file = pipeline_config_file or get(
"DEFAULT_PIPELINE_CONFIG"
)
inject_env_vars
inject_env_vars(
node_params: Optional[
Union[Dict, List, str, int, float, bool]
] = None
) -> Optional[Union[Dict, List, str, int, float, bool]]
Inject environment variables into node params.
This function is used to recursively inject environment variables into strings passed through node params via the pipeline config. We only recursively parse strings, dicts, and lists, as these are the only types that can contain environment variables (i.e. excluding ints, floats, and Nones).
Environment variables are identified in strings by the pattern {$ENV_VAR} where ENV_VAR is the name of the environment variable to inject. For example, given the following environment variables:
$ export SECRET1=secret1
$ export SECRET2=secret2
The following node params dict:
```
{
"key1": "A string with a {$SECRET1} and a {$SECRET2}.",
"key2": {
"key3": "A string with a {$SECRET1} and a {$SECRET2}.",
"key4": [
"A string with a {$SECRET1} and a {$SECRET2}.",
"A string with a {$SECRET1} and a {$SECRET2}."
]
}
}
```
Will be transformed to:
```
{
"key1": "A string with a secret1 and a secret2.",
"key2": {
"key3": "A string with a secret1 and a secret2.",
"key4": [
"A string with a secret1 and a secret2.",
"A string with a secret1 and a secret2."
]
}
}
```
Source code in aineko/core/config_loader.py
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 |
|
load_config
load_config() -> Config
Load and validate the pipeline config.
Raises:
Type | Description |
---|---|
ValidationError
|
If the config does not match the schema |
Returns:
Type | Description |
---|---|
Config
|
The validated pipeline config as a Pydantic Config object |
Source code in aineko/core/config_loader.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|