out: properly remove outputs when reproducing

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-06-04 22:28:15 +03:00
parent 331e3b2bf9
commit 346ef139dd
6 changed files with 34 additions and 12 deletions
+1 -5
View File
@@ -41,8 +41,4 @@ class OutputGS(DependencyGS):
self.info = self.project.cache.gs.save(self.path_info)
def remove(self):
blob = self.client.bucket(self.bucket).get_blob(self.key)
if not blob:
return
blob.delete()
self.remote.remove(self.path_info)
+1 -1
View File
@@ -72,4 +72,4 @@ class OutputLOCAL(DependencyLOCAL):
self.info = self.project.cache.local.save(self.path_info)
def remove(self):
remove(self.path)
self.remote.remove(self.path_info)
+1 -1
View File
@@ -40,4 +40,4 @@ class OutputS3(DependencyS3):
self.info = self.project.cache.s3.save(self.path_info)
def remove(self):
self.s3.Object(self.bucket, self.key).delete()
self.remote.remove(self.path_info)
+15 -5
View File
@@ -16,7 +16,7 @@ class RemoteGS(RemoteBase):
def __init__(self, project, config):
self.project = project
self.url = config.get[Config.SECTION_REMOTE_URL]
self.url = config[Config.SECTION_REMOTE_URL]
self.projectname = config.get(Config.SECTION_GCP_PROJECTNAME, None)
@property
@@ -55,15 +55,15 @@ class RemoteGS(RemoteBase):
if not blob:
raise DvcException('{} doesn\'t exist in the cloud'.format(path_info['key']))
self.gs.bucket(self.bucket).copy_blob(blob, self.bucket, name=dest_key)
self.gs.bucket(self.bucket).copy_blob(blob, self.gs.bucket(path_info['bucket']), new_name=dest_key)
return {PARAM_ETAG: etag}
return {self.PARAM_ETAG: etag}
def checkout(self, path_info, checksum_info):
if path_info['scheme'] != 'gs':
raise NotImplementedError
etag = checksum_info.get(PARAM_ETAG, None)
etag = checksum_info.get(self.PARAM_ETAG, None)
if not etag:
return
@@ -72,4 +72,14 @@ class RemoteGS(RemoteBase):
if not blob:
raise DvcException('{} doesn\'t exist in the cloud'.format(key))
self.gs.bucket(path_info['bucket']).copy_blob(blob, path_info['bucket'], name=path_info['key'])
self.gs.bucket(path_info['bucket']).copy_blob(blob, self.gs.bucket(self.bucket), new_name=path_info['key'])
def remove(self, path_info):
if path_info['scheme'] != 'gs':
raise NotImplementedError
blob = self.gs.bucket(path_info['key']).get_blob(path_info['key'])
if not blob:
return
blob.delete()
+6
View File
@@ -225,3 +225,9 @@ class RemoteLOCAL(RemoteBase):
raise NotImplementedError
return {self.PARAM_MD5: self.state.update(path_info['path'])}
def remove(self, path_info):
if path_info['scheme'] != 'local':
raise NotImplementedError
remove(path_info['path'])
+10
View File
@@ -73,3 +73,13 @@ class RemoteS3(RemoteBase):
'Key': key}
self.s3.Bucket(path_info['bucket']).copy(source, path_info['key'])
def remove(self, path_info):
if path_info['scheme'] != 's3':
raise NotImplementedError
try:
obj = self.s3.Object(path_info['bucket'], path_info['key']).get()
obj.delete()
except Exception:
pass