mirror of
https://github.com/clearml/clearml
synced 2025-06-26 18:16:07 +00:00
Add multi configuration section support (hyperparams and configurations)
Support setting offline mode API version using TRAINS_OFFLINE_MODE env var
This commit is contained in:
@@ -64,7 +64,11 @@ class DataModel(object):
|
||||
|
||||
@classmethod
|
||||
def _to_base_type(cls, value):
|
||||
if isinstance(value, DataModel):
|
||||
if isinstance(value, dict):
|
||||
# Note: this should come before DataModel to handle data models that are simply a dict
|
||||
# (and thus are not expected to have additional named properties)
|
||||
return {k: cls._to_base_type(v) for k, v in value.items()}
|
||||
elif isinstance(value, DataModel):
|
||||
return value.to_dict()
|
||||
elif isinstance(value, enum.Enum):
|
||||
return value.value
|
||||
|
||||
@@ -62,6 +62,7 @@ class Session(TokenManager):
|
||||
default_files = "https://demofiles.trains.allegro.ai"
|
||||
default_key = "EGRTCO8JMSIGI6S39GTP43NFWXDQOW"
|
||||
default_secret = "x!XTov_G-#vspE*Y(h$Anm&DIc5Ou-F)jsl$PdOyj5wG1&E!Z8"
|
||||
force_max_api_version = None
|
||||
|
||||
# TODO: add requests.codes.gateway_timeout once we support async commits
|
||||
_retry_codes = [
|
||||
@@ -182,6 +183,9 @@ class Session(TokenManager):
|
||||
|
||||
self.__class__._sessions_created += 1
|
||||
|
||||
if self.force_max_api_version and self.check_min_api_version(self.force_max_api_version):
|
||||
Session.api_version = str(self.force_max_api_version)
|
||||
|
||||
def _send_request(
|
||||
self,
|
||||
service,
|
||||
@@ -539,7 +543,17 @@ class Session(TokenManager):
|
||||
# If no session was created, create a default one, in order to get the backend api version.
|
||||
if cls._sessions_created <= 0:
|
||||
if cls._offline_mode:
|
||||
cls.api_version = cls._offline_default_version
|
||||
# allow to change the offline mode version by setting ENV_OFFLINE_MODE to the required API version
|
||||
if cls.api_version != cls._offline_default_version:
|
||||
offline_api = ENV_OFFLINE_MODE.get(converter=lambda x: x)
|
||||
if offline_api:
|
||||
try:
|
||||
# check cast to float, but leave original str if we pass it.
|
||||
float(offline_api)
|
||||
cls._offline_default_version = str(offline_api)
|
||||
except ValueError:
|
||||
pass
|
||||
cls.api_version = cls._offline_default_version
|
||||
else:
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user