mirror of
https://github.com/clearml/clearml
synced 2025-01-31 17:17:00 +00:00
Fix OS env var TRAINS_OFFLINE_MODE set to API version (e.g. 2.9)
This commit is contained in:
parent
65003a168a
commit
b710c2f19d
@ -1,4 +1,5 @@
|
|||||||
from ...backend_config import EnvEntry
|
from ...backend_config import EnvEntry
|
||||||
|
from ...backend_config.converters import safe_text_to_bool
|
||||||
|
|
||||||
|
|
||||||
ENV_HOST = EnvEntry("TRAINS_API_HOST", "ALG_API_HOST")
|
ENV_HOST = EnvEntry("TRAINS_API_HOST", "ALG_API_HOST")
|
||||||
@ -8,4 +9,4 @@ ENV_ACCESS_KEY = EnvEntry("TRAINS_API_ACCESS_KEY", "ALG_API_ACCESS_KEY")
|
|||||||
ENV_SECRET_KEY = EnvEntry("TRAINS_API_SECRET_KEY", "ALG_API_SECRET_KEY")
|
ENV_SECRET_KEY = EnvEntry("TRAINS_API_SECRET_KEY", "ALG_API_SECRET_KEY")
|
||||||
ENV_VERBOSE = EnvEntry("TRAINS_API_VERBOSE", "ALG_API_VERBOSE", type=bool, default=False)
|
ENV_VERBOSE = EnvEntry("TRAINS_API_VERBOSE", "ALG_API_VERBOSE", type=bool, default=False)
|
||||||
ENV_HOST_VERIFY_CERT = EnvEntry("TRAINS_API_HOST_VERIFY_CERT", "ALG_API_HOST_VERIFY_CERT", type=bool, default=True)
|
ENV_HOST_VERIFY_CERT = EnvEntry("TRAINS_API_HOST_VERIFY_CERT", "ALG_API_HOST_VERIFY_CERT", type=bool, default=True)
|
||||||
ENV_OFFLINE_MODE = EnvEntry("TRAINS_OFFLINE_MODE", "ALG_OFFLINE_MODE", type=bool)
|
ENV_OFFLINE_MODE = EnvEntry("TRAINS_OFFLINE_MODE", "ALG_OFFLINE_MODE", type=bool, converter=safe_text_to_bool)
|
||||||
|
@ -549,8 +549,9 @@ class Session(TokenManager):
|
|||||||
if offline_api:
|
if offline_api:
|
||||||
try:
|
try:
|
||||||
# check cast to float, but leave original str if we pass it.
|
# check cast to float, but leave original str if we pass it.
|
||||||
float(offline_api)
|
# minimum version is 2.3
|
||||||
cls._offline_default_version = str(offline_api)
|
if float(offline_api) >= 2.3:
|
||||||
|
cls._offline_default_version = str(offline_api)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
cls.api_version = cls._offline_default_version
|
cls.api_version = cls._offline_default_version
|
||||||
|
@ -24,6 +24,14 @@ def text_to_bool(value):
|
|||||||
return bool(strtobool(value))
|
return bool(strtobool(value))
|
||||||
|
|
||||||
|
|
||||||
|
def safe_text_to_bool(value):
|
||||||
|
# type: (Text) -> bool
|
||||||
|
try:
|
||||||
|
return bool(strtobool(value))
|
||||||
|
except ValueError:
|
||||||
|
return bool(value)
|
||||||
|
|
||||||
|
|
||||||
def any_to_bool(value):
|
def any_to_bool(value):
|
||||||
# type: (Optional[Union[int, float, Text]]) -> bool
|
# type: (Optional[Union[int, float, Text]]) -> bool
|
||||||
if isinstance(value, six.text_type):
|
if isinstance(value, six.text_type):
|
||||||
|
Loading…
Reference in New Issue
Block a user