diff --git a/dvc/cli.py b/dvc/cli.py index 1f9281e59..f0a1556fb 100644 --- a/dvc/cli.py +++ b/dvc/cli.py @@ -10,7 +10,7 @@ from dvc.command.init import CmdInit from dvc.command.remove import CmdRemove from dvc.command.run import CmdRun from dvc.command.repro import CmdRepro -from dvc.command.data_sync import CmdDataPush, CmdDataPull, CmdDataStatus +from dvc.command.data_sync import CmdDataPush, CmdDataPull, CmdDataStatus, CmdDataFetch from dvc.command.gc import CmdGC from dvc.command.add import CmdAdd from dvc.command.config import CmdConfig @@ -161,6 +161,13 @@ def parse_args(argv=None): help='Push data files to the cloud') push_parser.set_defaults(func=CmdDataPush) + #Fetch + fetch_parser = cache_subparsers.add_parser( + 'fetch', + parents=[parent_cache_parser], + help='Fetch data files from the cloud') + fetch_parser.set_defaults(func=CmdDataFetch) + # Status status_parser = cache_subparsers.add_parser( 'status', diff --git a/dvc/command/data_sync.py b/dvc/command/data_sync.py index f4f5f9562..d337245ce 100644 --- a/dvc/command/data_sync.py +++ b/dvc/command/data_sync.py @@ -40,6 +40,16 @@ class CmdDataPush(CmdDataBase): return 0 +class CmdDataFetch(CmdDataBase): + def do_run(self, target=None): + try: + self.project.fetch(target=target, jobs=self.args.jobs) + except DvcException as exc: + self.project.logger.error('Failed to fetch data from the cloud', exc) + return 1 + return 0 + + class CmdDataStatus(CmdDataBase): def _show(self, status): for s in status: diff --git a/dvc/project.py b/dvc/project.py index 9d6d486ca..dc5478849 100644 --- a/dvc/project.py +++ b/dvc/project.py @@ -201,8 +201,11 @@ class Project(object): def push(self, target=None, jobs=1): return self.cloud.push(self._used_cache(target), jobs) + def fetch(self, target=None, jobs=1): + return self.cloud.pull(self._used_cache(target), jobs) + def pull(self, target=None, jobs=1): - ret = self.cloud.pull(self._used_cache(target), jobs) + ret = self.fetch(target, jobs) self.checkout() return ret