From fcba19d1747935afebd0e8e1abb64d1354e19109 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Fri, 16 Jun 2023 16:42:12 +0300 Subject: [PATCH] api: show/exp: add config option Fixes #9613 --- dvc/api/experiments.py | 5 ++++- dvc/api/show.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dvc/api/experiments.py b/dvc/api/experiments.py index ba9ff750ad9..4cc9e2fc00a 100644 --- a/dvc/api/experiments.py +++ b/dvc/api/experiments.py @@ -65,6 +65,7 @@ def exp_show( num: int = 1, param_deps: bool = False, force: bool = False, + config: dict = None, ) -> List[Dict]: """Get DVC experiments tracked in `repo`. @@ -99,13 +100,15 @@ def exp_show( When `force` is specified, DVC will reload all experiment data and ignore any previously cached results. Defaults to `False`. + config (dict, optional): config to be passed through to DVC project. + Defaults to `None`. Returns: List[Dict]: Each item in the list will contain a dictionary with the info for an individual experiment. See Examples below. """ - with Repo.open(repo) as _repo: + with Repo.open(repo, config=config) as _repo: experiments = _repo.experiments.show( revs=revs, num=num, diff --git a/dvc/api/show.py b/dvc/api/show.py index a9156dcb216..a24376166e2 100644 --- a/dvc/api/show.py +++ b/dvc/api/show.py @@ -41,6 +41,7 @@ def metrics_show( *targets: str, repo: Optional[str] = None, rev: Optional[str] = None, + config: Optional[dict] = None, ) -> Dict: """Get metrics tracked in `repo`. @@ -69,6 +70,8 @@ def metrics_show( hash or a dvc experiment name. If `repo` is not a Git repo, this option is ignored. If `None`, the current working tree will be used. + config (dict, optional): config to be passed through to DVC project. + Defaults to `None`. Returns: Dict: See Examples below. @@ -136,7 +139,7 @@ def metrics_show( https://git-scm.com/docs/revisions """ - with Repo.open(repo) as _repo: + with Repo.open(repo, config=config) as _repo: metrics = _repo.metrics.show( targets=targets, revs=rev if rev is None else [rev], @@ -157,6 +160,7 @@ def params_show( stages: Optional[Union[str, Iterable[str]]] = None, rev: Optional[str] = None, deps: bool = False, + config: Optional[dict] = None, ) -> Dict: """Get parameters tracked in `repo`. @@ -195,6 +199,8 @@ def params_show( deps (bool, optional): Whether to retrieve only parameters that are stage dependencies or not. Defaults to `False`. + config (dict, optional): config to be passed through to DVC project. + Defaults to `None`. Returns: Dict: See Examples below. @@ -379,7 +385,7 @@ def params_show( if isinstance(stages, str): stages = [stages] - with Repo.open(repo) as _repo: + with Repo.open(repo, config=config) as _repo: params = _repo.params.show( revs=rev if rev is None else [rev], targets=targets,