MCPcopy
hub / github.com/treeverse/dvc / parse_params

Function parse_params

dvc/utils/cli_parse.py:5–17  ·  view source on GitHub ↗

Normalizes the shape of params from the CLI to dict.

(path_params: Iterable[str])

Source from the content-addressed store, hash-verified

3
4
5def 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
20def to_path_overrides(path_params: Iterable[str]) -> dict[str, list[str]]:

Callers 3

runMethod · 0.90
runFunction · 0.90
test_parse_paramsFunction · 0.90

Calls 2

extendMethod · 0.80
itemsMethod · 0.80

Tested by 1

test_parse_paramsFunction · 0.72