mirror of
https://github.com/clearml/clearml
synced 2025-04-16 13:33:10 +00:00
Explicitly request raising an error when failing to check api version
This commit is contained in:
parent
f67ce9c04b
commit
3d6ab41a7a
@ -34,7 +34,7 @@ class ApiServiceProxy(object):
|
||||
# get the most advanced service version that supports our api
|
||||
version = [
|
||||
str(v) for v in ApiServiceProxy._available_versions
|
||||
if Session.check_min_api_version(v, raise_error=False)
|
||||
if Session.check_min_api_version(v)
|
||||
][-1]
|
||||
Session.api_version = version
|
||||
self.__dict__["__wrapped_version__"] = Session.api_version
|
||||
|
@ -737,7 +737,7 @@ class Session(TokenManager):
|
||||
return urlunparse(parsed)
|
||||
|
||||
@classmethod
|
||||
def check_min_api_version(cls, min_api_version, raise_error=True):
|
||||
def check_min_api_version(cls, min_api_version, raise_error=False):
|
||||
"""
|
||||
Return True if Session.api_version is greater or equal >= to min_api_version
|
||||
"""
|
||||
@ -774,12 +774,12 @@ class Session(TokenManager):
|
||||
return cls._version_tuple(cls.api_version) >= cls._version_tuple(str(min_api_version))
|
||||
|
||||
@classmethod
|
||||
def check_min_api_server_version(cls, min_api_version):
|
||||
def check_min_api_server_version(cls, min_api_version, raise_error=False):
|
||||
"""
|
||||
Return True if Session.max_api_version is greater or equal >= to min_api_version
|
||||
Notice this is the api version server reported, not the current SDK max supported api version
|
||||
"""
|
||||
if cls.check_min_api_version(min_api_version):
|
||||
if cls.check_min_api_version(min_api_version, raise_error=raise_error):
|
||||
return True
|
||||
|
||||
return cls._version_tuple(cls.max_api_version) >= cls._version_tuple(str(min_api_version))
|
||||
|
@ -79,7 +79,7 @@ class Model(IdObjectBase, AsyncManagerMixin, _StorageUriMixin):
|
||||
self.reload()
|
||||
|
||||
def archive(self):
|
||||
if Session.check_min_api_server_version("2.13"):
|
||||
if Session.check_min_api_server_version("2.13", raise_error=True):
|
||||
self.send(models.ArchiveManyRequest(ids=[self.id]))
|
||||
self.reload()
|
||||
else:
|
||||
@ -90,7 +90,7 @@ class Model(IdObjectBase, AsyncManagerMixin, _StorageUriMixin):
|
||||
)
|
||||
|
||||
def unarchive(self):
|
||||
if Session.check_min_api_server_version("2.13"):
|
||||
if Session.check_min_api_server_version("2.13", raise_error=True):
|
||||
self.send(models.UnarchiveManyRequest(ids=[self.id]))
|
||||
self.reload()
|
||||
else:
|
||||
|
@ -1346,7 +1346,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
||||
return params.get(name, default)
|
||||
|
||||
def delete_parameter(self, name, force=False):
|
||||
# type: (str) -> bool
|
||||
# type: (str, bool) -> bool
|
||||
"""
|
||||
Delete a parameter by its full name Section/name.
|
||||
|
||||
|
@ -1241,7 +1241,7 @@ class Dataset(object):
|
||||
|
||||
:return: Newly created Dataset object
|
||||
"""
|
||||
if not Dataset.is_offline() and not Session.check_min_api_server_version("2.13"):
|
||||
if not Dataset.is_offline() and not Session.check_min_api_server_version("2.13", raise_error=True):
|
||||
raise NotImplementedError("Datasets are not supported with your current ClearML server version. Please update your server.")
|
||||
|
||||
parent_datasets = [cls.get(dataset_id=p) if not isinstance(p, Dataset) else p for p in (parent_datasets or [])]
|
||||
@ -1531,7 +1531,7 @@ class Dataset(object):
|
||||
"""
|
||||
if Dataset.is_offline():
|
||||
raise ValueError("Cannot rename dataset in offline mode")
|
||||
if not bool(Session.check_min_api_server_version(cls.__min_api_version)):
|
||||
if not bool(Session.check_min_api_server_version(cls.__min_api_version, raise_error=True)):
|
||||
LoggerRoot.get_base_logger().warning(
|
||||
"Could not rename dataset because API version < {}".format(cls.__min_api_version)
|
||||
)
|
||||
@ -1578,7 +1578,7 @@ class Dataset(object):
|
||||
"""
|
||||
if cls.is_offline():
|
||||
raise ValueError("Cannot move dataset project in offlime mode")
|
||||
if not bool(Session.check_min_api_server_version(cls.__min_api_version)):
|
||||
if not bool(Session.check_min_api_server_version(cls.__min_api_version, raise_error=True)):
|
||||
LoggerRoot.get_base_logger().warning(
|
||||
"Could not move dataset to another project because API version < {}".format(cls.__min_api_version)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user