mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-08 15:28:26 +01:00
dvc: introduce 'dvc cache fetch'
Fixes #521 Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
+8
-1
@@ -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',
|
||||
|
||||
@@ -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:
|
||||
|
||||
+4
-1
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user