From d63d1db5b6277c6780db1818ee38e3d76460fb25 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 11 Jul 2018 17:44:38 +0300 Subject: [PATCH] gc: introduce -c|--cloud Fixes #876 Signed-off-by: Ruslan Kuprieiev --- dvc/cli.py | 8 ++++++++ dvc/command/gc.py | 4 +++- dvc/project.py | 5 ++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dvc/cli.py b/dvc/cli.py index aaddf1e73..a8f18de8c 100644 --- a/dvc/cli.py +++ b/dvc/cli.py @@ -314,6 +314,14 @@ def parse_args(argv=None): action='store_true', default=False, help='Collect garbage for all branches.') + gc_parser.add_argument('-c', + '--cloud', + action='store_true', + default=False, + help='Collect garbage in remote repository') + gc_parser.add_argument('-r', + '--remote', + help='Remote repository to collect garbage in') gc_parser.set_defaults(func=CmdGC) # Config diff --git a/dvc/command/gc.py b/dvc/command/gc.py index a4230f58d..19c4c0036 100644 --- a/dvc/command/gc.py +++ b/dvc/command/gc.py @@ -3,5 +3,7 @@ from dvc.command.common.base import CmdBase class CmdGC(CmdBase): def run(self): - self.project.gc() + self.project.gc(all_branches=self.args.all_branches, + cloud=self.args.cloud, + remote=self.args.remote) return 0 diff --git a/dvc/project.py b/dvc/project.py index 5b8080300..7c74e66cc 100644 --- a/dvc/project.py +++ b/dvc/project.py @@ -291,7 +291,7 @@ class Project(object): return cache - def gc(self, all_branches=False): + def gc(self, all_branches=False, cloud=False, remote=None): clist = self._used_cache(target=None, all_branches=all_branches) self.cache.local.gc(clist) @@ -310,6 +310,9 @@ class Project(object): if self.cache.azure: self.cache.azure.gc(clist) + if cloud: + self.cloud._get_cloud(remote).gc(clist) + def push(self, target=None, jobs=1, remote=None, all_branches=False): self.cloud.push(self._used_cache(target, all_branches)['local'], jobs, remote=remote)