From 1fef71ba8ad29dce14e4664534181bb40c1cb7ac Mon Sep 17 00:00:00 2001 From: Peter Rowlands Date: Thu, 14 Apr 2022 17:30:38 +0900 Subject: [PATCH 1/2] exp show: don't acquire repo lock --- dvc/repo/experiments/show.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dvc/repo/experiments/show.py b/dvc/repo/experiments/show.py index 8fa375b13c..47ba2fe18a 100644 --- a/dvc/repo/experiments/show.py +++ b/dvc/repo/experiments/show.py @@ -1,15 +1,17 @@ import logging from collections import OrderedDict, defaultdict from datetime import datetime -from typing import Any, Callable, Dict, List, Optional, Union +from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union -from dvc.repo import Repo, locked # pylint: disable=unused-import from dvc.repo.experiments.base import ExpRefInfo from dvc.repo.metrics.show import _gather_metrics from dvc.repo.params.show import _gather_params from dvc.scm import iter_revs from dvc.utils import error_handler, onerror_collect +if TYPE_CHECKING: + from dvc.repo import Repo + logger = logging.getLogger(__name__) @@ -124,7 +126,6 @@ def _collect_experiment_branch( return res -@locked def show( repo: "Repo", all_branches=False, From 79e6a70b52c9bb871d8582bc38f38c095443507b Mon Sep 17 00:00:00 2001 From: Peter Rowlands Date: Thu, 14 Apr 2022 17:50:36 +0900 Subject: [PATCH 2/2] exp show: add internal --no-fetch option to disable temp/queue ref fetch --- dvc/commands/experiments/show.py | 7 +++++++ dvc/repo/experiments/__init__.py | 4 ++-- dvc/repo/experiments/show.py | 3 ++- tests/unit/command/test_experiments.py | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dvc/commands/experiments/show.py b/dvc/commands/experiments/show.py index 6f01f76027..59fe267268 100644 --- a/dvc/commands/experiments/show.py +++ b/dvc/commands/experiments/show.py @@ -480,6 +480,7 @@ def run(self): num=self.args.num, sha_only=self.args.sha, param_deps=self.args.param_deps, + fetch_running=self.args.fetch_running, ) except DvcException: logger.exception("failed to show experiments") @@ -645,4 +646,10 @@ def add_parser(experiments_subparsers, parent_parser): default=False, help="Open the Parallel Coordinates Plot directly in the browser.", ) + experiments_show_parser.add_argument( + "--no-fetch", + dest="fetch_running", + action="store_false", + help=argparse.SUPPRESS, + ) experiments_show_parser.set_defaults(func=CmdExperimentsShow) diff --git a/dvc/repo/experiments/__init__.py b/dvc/repo/experiments/__init__.py index 811afb3186..48c07adca6 100644 --- a/dvc/repo/experiments/__init__.py +++ b/dvc/repo/experiments/__init__.py @@ -742,7 +742,7 @@ def get_exact_name(self, rev: str): return self.stash_revs[rev].name return None - def get_running_exps(self) -> Dict[str, int]: + def get_running_exps(self, fetch_refs: bool = True) -> Dict[str, int]: """Return info for running experiments.""" from dvc.scm import InvalidRemoteSCMRepo from dvc.utils.serialize import load_json @@ -774,7 +774,7 @@ def get_running_exps(self) -> Dict[str, int]: result[rev] = info.asdict() else: result[rev] = info.asdict() - if info.git_url: + if info.git_url and fetch_refs: def on_diverged(_ref: str, _checkpoint: bool): return False diff --git a/dvc/repo/experiments/show.py b/dvc/repo/experiments/show.py index 47ba2fe18a..3c28ac7ca8 100644 --- a/dvc/repo/experiments/show.py +++ b/dvc/repo/experiments/show.py @@ -136,6 +136,7 @@ def show( num=1, param_deps=False, onerror: Optional[Callable] = None, + fetch_running: bool = True, ): if onerror is None: @@ -153,7 +154,7 @@ def show( iter_revs(repo.scm, revs, num, all_branches, all_tags, all_commits) ) - running = repo.experiments.get_running_exps() + running = repo.experiments.get_running_exps(fetch_refs=fetch_running) for rev in found_revs: res[rev]["baseline"] = _collect_experiment_commit( diff --git a/tests/unit/command/test_experiments.py b/tests/unit/command/test_experiments.py index 8d4f2ee4a4..6bc5828450 100644 --- a/tests/unit/command/test_experiments.py +++ b/tests/unit/command/test_experiments.py @@ -118,6 +118,7 @@ def test_experiments_show(dvc, scm, mocker): revs="foo", sha_only=True, param_deps=True, + fetch_running=True, )