data_config_parser ¶
Module for parsing data configs.
Functions:
-
create_encoders
–Factory for creating encoders from config.
-
create_splitter
–Factory for creating splitters from config.
-
create_transforms
–Factory for creating transforms from config.
-
dump_yaml_list_into_files
–Dumps YAML configurations to files with consistent, readable formatting.
-
expand_transform_list_combinations
–Expands a list of transforms into all possible parameter combinations.
-
expand_transform_parameter_combinations
–Get all possible transforms by extracting parameters at each valid index.
-
extract_transform_parameters_at_index
–Get a transform with parameters at the specified index.
-
generate_split_configs
–Generates all possible split configuration from a YAML config.
-
generate_split_transform_configs
–Generates all the transform configuration for a given split.
-
parse_split_transform_config
–Parse the configuration and return a dictionary of the parsed configuration.
create_encoders ¶
create_encoders(
column_config: list[Columns],
) -> dict[str, AbstractEncoder]
Factory for creating encoders from config.
Source code in src/stimulus/data/interface/data_config_parser.py
37 38 39 40 41 42 43 44 45 46 |
|
create_splitter ¶
create_splitter(split_config: Split) -> AbstractSplitter
Factory for creating splitters from config.
Source code in src/stimulus/data/interface/data_config_parser.py
72 73 74 75 76 77 78 |
|
create_transforms ¶
Factory for creating transforms from config.
Parameters:
Returns:
Source code in src/stimulus/data/interface/data_config_parser.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
dump_yaml_list_into_files ¶
dump_yaml_list_into_files(
yaml_list: list[SplitConfigDict],
directory_path: str,
base_name: str,
len_simple_numeric: int = 5,
) -> None
Dumps YAML configurations to files with consistent, readable formatting.
Source code in src/stimulus/data/interface/data_config_parser.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|
expand_transform_list_combinations ¶
Expands a list of transforms into all possible parameter combinations.
Takes a list of transforms where each transform may contain parameter lists, and expands them into separate transforms with single parameter values. For example, if a transform has parameters [0.1, 0.2] and [1, 2], this will create two transforms: one with 0.1/1 and another with 0.2/2.
Parameters:
-
transform_list
(list[Transform]
) –A list of YamlTransform objects containing parameter lists that need to be expanded into individual transforms.
Returns:
-
list[Transform]
–list[YamlTransform]: A flattened list of transforms where each transform has single parameter values instead of parameter lists. The length of the returned list will be the sum of the number of parameter combinations for each input transform.
Source code in src/stimulus/data/interface/data_config_parser.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
expand_transform_parameter_combinations ¶
Get all possible transforms by extracting parameters at each valid index.
For a transform with parameter lists, creates multiple new transforms, each containing single parameter values from the corresponding indices of the parameter lists.
Parameters:
-
transform
(Transform
) –The original transform containing parameter lists
Returns:
Source code in src/stimulus/data/interface/data_config_parser.py
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 |
|
extract_transform_parameters_at_index ¶
Get a transform with parameters at the specified index.
Parameters:
-
transform
(Transform
) –The original transform containing parameter lists
-
index
(int
, default:0
) –Index to extract parameters from (default 0)
Returns:
-
Transform
–A new transform with single parameter values at the specified index
Source code in src/stimulus/data/interface/data_config_parser.py
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 |
|
generate_split_configs ¶
generate_split_configs(
config: ConfigDict,
) -> list[SplitConfigDict]
Generates all possible split configuration from a YAML config.
Takes a YAML configuration that may contain parameter lists and splits, and generates all unique splits into separate data configurations.
For example, if the config has: - Two transforms with parameters [0.1, 0.2], [0.3, 0.4] - Two splits [0.7/0.3] and [0.8/0.2] This will generate 2 configs, 2 for each split. config_1: transform: [[0.1, 0.2], [0.3, 0.4]] split: [0.7, 0.3]
config_2:
transform: [[0.1, 0.2], [0.3, 0.4]]
split: [0.8, 0.2]
Parameters:
-
config
(ConfigDict
) –The source YAML configuration containing transforms with parameter lists and multiple splits.
Returns:
-
list[SplitConfigDict]
–list[SplitConfigDict]: A list of data configurations, where each config has a list of parameters and one split configuration. The length will be the product of the number of parameter combinations and the number of splits.
Source code in src/stimulus/data/interface/data_config_parser.py
196 197 198 199 200 201 202 203 204 205 206 207 208 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 |
|
generate_split_transform_configs ¶
generate_split_transform_configs(
config: SplitConfigDict,
) -> list[SplitTransformDict]
Generates all the transform configuration for a given split.
Takes a YAML configuration that may contain a transform or a list of transform, and generates all unique transform for a split into separate data configurations.
For example, if the config has: - Two transforms with parameters [0.1, 0.2], [0.3, 0.4] - A split [0.7, 0.3] This will generate 2 configs, 2 for each split. transform_config_1: transform: [0.1, 0.2] split: [0.7, 0.3]
transform_config_2:
transform: [0.3, 0.4]
split: [0.7, 0.3]
Parameters:
-
config
(SplitConfigDict
) –The source YAML configuration containing each a split with transforms with parameters lists
Returns:
-
list[SplitTransformDict]
–list[SplitTransformDict]: A list of data configurations, where each config has a list of parameters and one split configuration. The length will be the product of the number of parameter combinations and the number of splits.
Source code in src/stimulus/data/interface/data_config_parser.py
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 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
parse_split_transform_config ¶
parse_split_transform_config(
config: SplitTransformDict,
) -> tuple[
dict[str, AbstractEncoder],
list[str],
list[str],
list[str],
]
Parse the configuration and return a dictionary of the parsed configuration.
Parameters:
-
config
(SplitTransformDict
) –The configuration to parse.
Returns:
-
tuple[dict[str, AbstractEncoder], list[str], list[str], list[str]]
–A tuple of the parsed configuration.
Source code in src/stimulus/data/interface/data_config_parser.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|