Skip to content

Commit dcce3a3

Browse files
authored
params diff: skip params dependency for vars (#5123)
* Skip paramdependency for vars Previously, `configs` which was a list of PathInfo was being used to check if the `vars` should be skipped or not. But, the file is stored as a string that made that check redundant which might have caused #5117 as they were being stored twice, once as a expanded paramdependency and next as a flattened dict from vars, which later during `flatten`, it might have panicked from that duplication. * Use defaultdict * change add_vars to collect_vars
1 parent 64dfaff commit dcce3a3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

dvc/repo/params/show.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
from collections import defaultdict
23
from typing import TYPE_CHECKING, List
34

45
from dvc.dependency.param import ParamsDependency
@@ -50,17 +51,18 @@ def _read_params(repo, configs, rev):
5051
return res
5152

5253

53-
def _add_vars(repo, configs, params):
54+
def _collect_vars(repo, params):
55+
vars_params = defaultdict(dict)
5456
for stage in repo.stages:
5557
if isinstance(stage, PipelineStage) and stage.tracked_vars:
5658
for file, vars_ in stage.tracked_vars.items():
5759
# `params` file are shown regardless of `tracked` or not
5860
# to reduce noise and duplication, they are skipped
59-
if file in configs:
61+
if file in params:
6062
continue
6163

62-
params[file] = params.get(file, {})
63-
params[file].update(vars_)
64+
vars_params[file].update(vars_)
65+
return vars_params
6466

6567

6668
@locked
@@ -70,7 +72,11 @@ def show(repo, revs=None):
7072
for branch in repo.brancher(revs=revs):
7173
configs = _collect_configs(repo, branch)
7274
params = _read_params(repo, configs, branch)
73-
_add_vars(repo, configs, params)
75+
vars_params = _collect_vars(repo, params)
76+
77+
# NOTE: only those that are not added as a ParamDependency are included
78+
# so we don't need to recursively merge them yet.
79+
params.update(vars_params)
7480

7581
if params:
7682
res[branch] = params

0 commit comments

Comments
 (0)