mirror of
https://github.com/clearml/clearml
synced 2025-01-31 00:56:57 +00:00
Add Model archive/unarchive methods
This commit is contained in:
parent
713501c611
commit
71c74f977b
@ -12,6 +12,7 @@ from ..storage import StorageManager
|
||||
from ..storage.helper import StorageHelper
|
||||
from ..utilities.async_manager import AsyncManagerMixin
|
||||
|
||||
|
||||
ModelPackage = namedtuple("ModelPackage", "weights design")
|
||||
|
||||
|
||||
@ -77,6 +78,28 @@ class Model(IdObjectBase, AsyncManagerMixin, _StorageUriMixin):
|
||||
self.send(models.SetReadyRequest(model=self.id, publish_task=False))
|
||||
self.reload()
|
||||
|
||||
def archive(self):
|
||||
if Session.check_min_api_server_version("2.13"):
|
||||
self.send(models.ArchiveManyRequest(ids=[self.id]))
|
||||
self.reload()
|
||||
else:
|
||||
from ..model import BaseModel
|
||||
# edit will reload
|
||||
self._edit(
|
||||
system_tags=list(set((self.data.system_tags or []) if hasattr(self.data, "system_tags") else []) | {BaseModel._archived_tag})
|
||||
)
|
||||
|
||||
def unarchive(self):
|
||||
if Session.check_min_api_server_version("2.13"):
|
||||
self.send(models.UnarchiveManyRequest(ids=[self.id]))
|
||||
self.reload()
|
||||
else:
|
||||
from ..model import BaseModel
|
||||
# edit will reload
|
||||
self._edit(
|
||||
system_tags=list(set((self.data.system_tags or []) if hasattr(self.data, "system_tags") else []) - {BaseModel._archived_tag})
|
||||
)
|
||||
|
||||
def _reload(self):
|
||||
"""Reload the model object"""
|
||||
if self._offline_mode:
|
||||
|
@ -1055,6 +1055,26 @@ class BaseModel(object):
|
||||
if not self.published:
|
||||
self._get_base_model().publish()
|
||||
|
||||
def archive(self):
|
||||
# type: () -> ()
|
||||
"""
|
||||
Archive the model. If the model is already archived, this is a no-op
|
||||
"""
|
||||
try:
|
||||
self._get_base_model().archive()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def unarchive(self):
|
||||
# type: () -> ()
|
||||
"""
|
||||
Unarchive the model. If the model is not archived, this is a no-op
|
||||
"""
|
||||
try:
|
||||
self._get_base_model().unarchive()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _init_reporter(self):
|
||||
if self._reporter:
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user