Normalizes the shape of params from the CLI to dict.
(path_params: Iterable[str])
| 3 | |
| 4 | |
| 5 | def parse_params(path_params: Iterable[str]) -> list[dict[str, list[str]]]: |
| 6 | """Normalizes the shape of params from the CLI to dict.""" |
| 7 | from dvc.dependency.param import ParamsDependency |
| 8 | |
| 9 | ret: dict[str, list[str]] = defaultdict(list) |
| 10 | for path_param in path_params: |
| 11 | path, _, params_str = path_param.rpartition(":") |
| 12 | # remove empty strings from params, on condition such as `-p "file1:"` |
| 13 | params = filter(bool, params_str.split(",")) |
| 14 | if not path: |
| 15 | path = ParamsDependency.DEFAULT_PARAMS_FILE |
| 16 | ret[path].extend(params) |
| 17 | return [{path: params} for path, params in ret.items()] |
| 18 | |
| 19 | |
| 20 | def to_path_overrides(path_params: Iterable[str]) -> dict[str, list[str]]: |