From fe0d6ec3e0bcd46ac154e141329c4612ec6a1c23 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 18 Dec 2020 12:09:22 +0545 Subject: [PATCH] params diff: skip params dependency for vars (bp #5123) (#5127) * 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 (cherry picked from commit dcce3a31a9b23bcec046656384966af439122065) Co-authored-by: Saugat Pachhai --- dvc/repo/params/show.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dvc/repo/params/show.py b/dvc/repo/params/show.py index a48d25048..e6199d185 100644 --- a/dvc/repo/params/show.py +++ b/dvc/repo/params/show.py @@ -1,4 +1,5 @@ import logging +from collections import defaultdict from typing import TYPE_CHECKING, List from dvc.dependency.param import ParamsDependency @@ -50,17 +51,18 @@ def _read_params(repo, configs, rev): return res -def _add_vars(repo, configs, params): +def _collect_vars(repo, params): + vars_params = defaultdict(dict) for stage in repo.stages: if isinstance(stage, PipelineStage) and stage.tracked_vars: for file, vars_ in stage.tracked_vars.items(): # `params` file are shown regardless of `tracked` or not # to reduce noise and duplication, they are skipped - if file in configs: + if file in params: continue - params[file] = params.get(file, {}) - params[file].update(vars_) + vars_params[file].update(vars_) + return vars_params @locked @@ -70,7 +72,11 @@ def show(repo, revs=None): for branch in repo.brancher(revs=revs): configs = _collect_configs(repo, branch) params = _read_params(repo, configs, branch) - _add_vars(repo, configs, params) + vars_params = _collect_vars(repo, params) + + # NOTE: only those that are not added as a ParamDependency are included + # so we don't need to recursively merge them yet. + params.update(vars_params) if params: res[branch] = params