Parse a list of values for the key if the value is a string. The values are separated by a comma. Modifies the config in place.
(config, key, dtype=int)
| 293 | |
| 294 | |
| 295 | def parse_list(config, key, dtype=int): |
| 296 | """Parse a list of values for the key if the value is a string. The values are separated by a comma. |
| 297 | Modifies the config in place. |
| 298 | """ |
| 299 | if key in config: |
| 300 | if isinstance(config[key], str): |
| 301 | config[key] = list(map(dtype, config[key].split(','))) |
| 302 | assert isinstance(config[key], list) and all([isinstance(e, dtype) for e in config[key]] |
| 303 | ), f"{key} should be a list of values dtype {dtype}. Given {config[key]} of type {type(config[key])} with values of type {[type(e) for e in config[key]]}." |
| 304 | |
| 305 | |
| 306 | def get_model_config(model_name, model_version=None): |