Merge pull request #994 from efiop/master

dvc: print a msg when there is no cache to remove
This commit is contained in:
Ruslan Kuprieiev
2018-08-10 19:30:49 +03:00
committed by GitHub
7 changed files with 36 additions and 7 deletions
+12 -7
View File
@@ -351,29 +351,34 @@ class Project(object):
return cache
def _do_gc(self, typ, func, clist):
removed = func(clist)
if not removed:
self.logger.info("No unused {} cache to remove.".format(typ))
def gc(self, all_branches=False, cloud=False, remote=None):
clist = self._used_cache(target=None,
all_branches=all_branches,
active=False)
self.cache.local.gc(clist)
self._do_gc('local', self.cache.local.gc, clist)
if self.cache.s3:
self.cache.s3.gc(clist)
self._do_gc('s3', self.cache.s3.gc, clist)
if self.cache.gs:
self.cache.gs.gc(clist)
self._do_gc('gs', self.cache.gs.gc, clist)
if self.cache.ssh:
self.cache.ssh.gc(clist)
self._do_gc('ssh', self.cache.ssh.gc, clist)
if self.cache.hdfs:
self.cache.hdfs.gc(clist)
self._do_gc('hdfs', self.cache.hdfs.gc, clist)
if self.cache.azure:
self.cache.azure.gc(clist)
self._do_gc('azure', self.cache.azure.gc, clist)
if cloud:
self.cloud._get_cloud(remote).gc(clist)
self._do_gc('remote', self.cloud._get_cloud(remote).gc, clist)
def push(self,
target=None,
+4
View File
@@ -227,6 +227,7 @@ class RemoteAzure(RemoteBase):
#
# all_blobs = self.blob_service.list_blobs(self.bucket)
#
# removed = False
# for blob in all_blobs:
# etag = blob.properties.etag
# if etag in used:
@@ -235,3 +236,6 @@ class RemoteAzure(RemoteBase):
# 'key': blob.name,
# 'bucket': self.bucket}
# self.remove(path_info)
# removed = True
#
# return removed
+4
View File
@@ -229,6 +229,7 @@ class RemoteGS(RemoteBase):
used = [info[self.PARAM_ETAG] for info in cinfos['gs']]
used += [info[RemoteLOCAL.PARAM_MD5] for info in cinfos['local']]
removed = False
for etag in self._all_etags():
if etag in used:
continue
@@ -237,3 +238,6 @@ class RemoteGS(RemoteBase):
'key': posixpath.join(self.prefix,
etag[0:2], etag[2:])}
self.remove(path_info)
removed = True
return removed
+4
View File
@@ -199,6 +199,7 @@ class RemoteHDFS(RemoteBase):
used = [info[self.PARAM_CHECKSUM] for info in cinfos['hdfs']]
used += [info[RemoteLOCAL.PARAM_MD5] for info in cinfos['local']]
removed = False
for checksum in self._all_checksums():
if checksum in used:
continue
@@ -207,3 +208,6 @@ class RemoteHDFS(RemoteBase):
'url': posixpath.join(self.url,
checksum[0:2], checksum[2:])}
self.remove(path_info)
removed = True
return removed
+4
View File
@@ -464,10 +464,14 @@ class RemoteLOCAL(RemoteBase):
checksum_infos = self._collect(checksum_infos['local'])[0]
used_md5s = [info[self.PARAM_MD5] for info in checksum_infos]
removed = False
for md5 in self.all():
if md5 in used_md5s:
continue
remove(self.get(md5))
removed = True
return removed
def status(self, checksum_infos, remote, jobs=1, show_checksums=False):
Logger.info("Preparing to pull data from {}".format(remote.url))
+4
View File
@@ -281,6 +281,7 @@ class RemoteS3(RemoteBase):
used_etags = [info[self.PARAM_ETAG] for info in cinfos['s3']]
used_etags += [info[RemoteLOCAL.PARAM_MD5] for info in cinfos['local']]
removed = False
for etag in self._all():
if etag in used_etags:
continue
@@ -289,3 +290,6 @@ class RemoteS3(RemoteBase):
etag[0:2], etag[2:]),
'bucket': self.bucket}
self.remove(path_info)
removed = True
return removed
+4
View File
@@ -289,6 +289,7 @@ class RemoteSSH(RemoteBase):
used = [info[self.PARAM_MD5] for info in cinfos['ssh']]
used += [info[RemoteLOCAL.PARAM_MD5] for info in cinfos['local']]
removed = False
for md5 in self._all_md5s():
if md5 in used:
continue
@@ -298,3 +299,6 @@ class RemoteSSH(RemoteBase):
'path': posixpath.join(self.prefix,
md5[0:2], md5[2:])}
self.remove(path_info)
removed = True
return removed