diff --git a/clearml_agent/commands/worker.py b/clearml_agent/commands/worker.py index 3289c83..ccabc4f 100644 --- a/clearml_agent/commands/worker.py +++ b/clearml_agent/commands/worker.py @@ -958,6 +958,7 @@ class Worker(ServiceCommandSection): if not (result.ok() and result.response): return new_session = copy(session) + new_session.api_client = None new_session.set_auth_token(result.response.token) return new_session diff --git a/clearml_agent/session.py b/clearml_agent/session.py index 6ca0b62..ee0226c 100644 --- a/clearml_agent/session.py +++ b/clearml_agent/session.py @@ -106,7 +106,7 @@ class Session(_Session): if os.path.exists(os.path.expanduser(os.path.expandvars(f))): self._config_file = f break - self.api_client = APIClient(session=self, api_version="2.5") + self._api_client = None # HACK make sure we have python version to execute, # if nothing was specific, use the one that runs us def_python = ConfigValue(self.config, "agent.default_python") @@ -167,6 +167,16 @@ class Session(_Session): if not kwargs.get('only_load_config'): self.create_cache_folders() + @property + def api_client(self): + if self._api_client is None: + self._api_client = APIClient(session=self, api_version="2.5") + return self._api_client + + @api_client.setter + def api_client(self, value): + self._api_client = value + @staticmethod def get_logger(name): logger = logging.getLogger(name)