mirror of
https://github.com/clearml/clearml
synced 2025-02-07 21:33:25 +00:00
Fix check_min_api_version to use a default session if none was created
This commit is contained in:
parent
085eebc6b9
commit
0be981fbc1
@ -41,6 +41,7 @@ class Session(TokenManager):
|
|||||||
_session_timeout = (10.0, 300.)
|
_session_timeout = (10.0, 300.)
|
||||||
_write_session_data_size = 15000
|
_write_session_data_size = 15000
|
||||||
_write_session_timeout = (300.0, 300.)
|
_write_session_timeout = (300.0, 300.)
|
||||||
|
_sessions_created = 0
|
||||||
|
|
||||||
api_version = '2.1'
|
api_version = '2.1'
|
||||||
default_host = "https://demoapi.trains.allegro.ai"
|
default_host = "https://demoapi.trains.allegro.ai"
|
||||||
@ -158,6 +159,8 @@ class Session(TokenManager):
|
|||||||
# notice: this is across the board warning omission
|
# notice: this is across the board warning omission
|
||||||
urllib_log_warning_setup(total_retries=http_retries_config.get('total', 0), display_warning_after=3)
|
urllib_log_warning_setup(total_retries=http_retries_config.get('total', 0), display_warning_after=3)
|
||||||
|
|
||||||
|
self.__class__._sessions_created += 1
|
||||||
|
|
||||||
def _send_request(
|
def _send_request(
|
||||||
self,
|
self,
|
||||||
service,
|
service,
|
||||||
@ -493,6 +496,14 @@ class Session(TokenManager):
|
|||||||
def version_tuple(v):
|
def version_tuple(v):
|
||||||
v = tuple(map(int, (v.split("."))))
|
v = tuple(map(int, (v.split("."))))
|
||||||
return v + (0,) * max(0, 3 - len(v))
|
return v + (0,) * max(0, 3 - len(v))
|
||||||
|
|
||||||
|
# If no session was created, create a default one, in order to get the backend api version.
|
||||||
|
if cls._sessions_created <= 0:
|
||||||
|
try:
|
||||||
|
dummy = cls()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
return version_tuple(cls.api_version) >= version_tuple(str(min_api_version))
|
return version_tuple(cls.api_version) >= version_tuple(str(min_api_version))
|
||||||
|
|
||||||
def _do_refresh_token(self, old_token, exp=None):
|
def _do_refresh_token(self, old_token, exp=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user