From 7f17c6aa03d9f86d43566137b9d7c26a2d3b551d Mon Sep 17 00:00:00 2001 From: nik123 Date: Mon, 11 May 2020 23:10:14 +0700 Subject: [PATCH] refactor: check if targets is instances of str (#3779) --- dvc/repo/checkout.py | 3 +++ dvc/repo/fetch.py | 3 +++ dvc/repo/pull.py | 3 +++ dvc/repo/push.py | 3 +++ dvc/repo/status.py | 3 +++ 5 files changed, 15 insertions(+) diff --git a/dvc/repo/checkout.py b/dvc/repo/checkout.py index ea5f7cdb8..eae723a1b 100644 --- a/dvc/repo/checkout.py +++ b/dvc/repo/checkout.py @@ -60,6 +60,9 @@ def _checkout( stats["deleted"] = [_fspath_dir(u, self.root_dir) for u in unused] self.state.remove_links(unused) + if isinstance(targets, str): + targets = [targets] + pairs = set() for target in targets: try: diff --git a/dvc/repo/fetch.py b/dvc/repo/fetch.py index cf2a01b76..a9534d2a4 100644 --- a/dvc/repo/fetch.py +++ b/dvc/repo/fetch.py @@ -37,6 +37,9 @@ def _fetch( used_run_cache = self.stage_cache.pull(remote) if run_cache else [] + if isinstance(targets, str): + targets = [targets] + used = self.used_cache( targets, all_branches=all_branches, diff --git a/dvc/repo/pull.py b/dvc/repo/pull.py index 16d160045..4ee782bad 100644 --- a/dvc/repo/pull.py +++ b/dvc/repo/pull.py @@ -19,6 +19,9 @@ def pull( all_commits=False, run_cache=False, ): + if isinstance(targets, str): + targets = [targets] + processed_files_count = self._fetch( targets, jobs, diff --git a/dvc/repo/push.py b/dvc/repo/push.py index 81e07ce6a..f0c88e298 100644 --- a/dvc/repo/push.py +++ b/dvc/repo/push.py @@ -16,6 +16,9 @@ def push( ): used_run_cache = self.stage_cache.push(remote) if run_cache else [] + if isinstance(targets, str): + targets = [targets] + used = self.used_cache( targets, all_branches=all_branches, diff --git a/dvc/repo/status.py b/dvc/repo/status.py index 5c0c452ff..6ea0294c3 100644 --- a/dvc/repo/status.py +++ b/dvc/repo/status.py @@ -116,6 +116,9 @@ def status( all_commits=False, recursive=False, ): + if isinstance(targets, str): + targets = [targets] + if cloud or remote: return _cloud_status( self,