mirror of
https://github.com/clearml/clearml
synced 2025-01-31 09:07:00 +00:00
Add Task.delete_artifacts()
with raise_on_errors
argument (#806)
* 'raise_on_errors' flag exposed to the parameters of Task._delete_artifacts() * indentation fixed * raise exceptions on errors by default on artifact deletions
This commit is contained in:
parent
ff73e7848c
commit
7f92e5b4ee
@ -1357,12 +1357,24 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
self._edit(execution=execution)
|
self._edit(execution=execution)
|
||||||
return self.data.execution.artifacts or []
|
return self.data.execution.artifacts or []
|
||||||
|
|
||||||
def _delete_artifacts(self, artifact_names):
|
def delete_artifacts(self, artifact_names, raise_on_errors=True):
|
||||||
# type: (Sequence[str]) -> bool
|
# type: (Sequence[str], bool) -> bool
|
||||||
"""
|
"""
|
||||||
Delete a list of artifacts, by artifact name, from the Task.
|
Delete a list of artifacts, by artifact name, from the Task.
|
||||||
|
|
||||||
:param list artifact_names: list of artifact names
|
:param list artifact_names: list of artifact names
|
||||||
|
:param bool raise_on_errors: if True, do not suppress connectivity related exceptions
|
||||||
|
:return: True if successful
|
||||||
|
"""
|
||||||
|
return self._delete_artifacts(artifact_names, raise_on_errors)
|
||||||
|
|
||||||
|
def _delete_artifacts(self, artifact_names, raise_on_errors=False):
|
||||||
|
# type: (Sequence[str], bool) -> bool
|
||||||
|
"""
|
||||||
|
Delete a list of artifacts, by artifact name, from the Task.
|
||||||
|
|
||||||
|
:param list artifact_names: list of artifact names
|
||||||
|
:param bool raise_on_errors: if True, do not suppress connectivity related exceptions
|
||||||
:return: True if successful
|
:return: True if successful
|
||||||
"""
|
"""
|
||||||
if not Session.check_min_api_version('2.3'):
|
if not Session.check_min_api_version('2.3'):
|
||||||
@ -1374,7 +1386,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
if Session.check_min_api_version("2.13") and not self._offline_mode:
|
if Session.check_min_api_version("2.13") and not self._offline_mode:
|
||||||
req = tasks.DeleteArtifactsRequest(
|
req = tasks.DeleteArtifactsRequest(
|
||||||
task=self.task_id, artifacts=[{"key": n, "mode": "output"} for n in artifact_names], force=True)
|
task=self.task_id, artifacts=[{"key": n, "mode": "output"} for n in artifact_names], force=True)
|
||||||
res = self.send(req, raise_on_errors=False)
|
res = self.send(req, raise_on_errors=raise_on_errors)
|
||||||
if not res or not res.response or not res.response.deleted:
|
if not res or not res.response or not res.response.deleted:
|
||||||
return False
|
return False
|
||||||
self.reload()
|
self.reload()
|
||||||
|
Loading…
Reference in New Issue
Block a user