From e4cb40f82b462a73e43a555525b5154042fe2a23 Mon Sep 17 00:00:00 2001 From: Victor Jouffrey <37411285+vatj@users.noreply.github.com> Date: Fri, 5 Apr 2024 13:59:03 +0200 Subject: [PATCH] [FSTORE-1320] Fix hopsworks.login second attempt not taking parameters into account (#192) (#196) * Cleanup client irrespective of whether connection was set * Reset client in connection before initialising it --- python/hopsworks/__init__.py | 5 +++-- python/hopsworks/client/__init__.py | 3 ++- python/hopsworks/connection.py | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/python/hopsworks/__init__.py b/python/hopsworks/__init__.py index b428527a0..23dcea9df 100644 --- a/python/hopsworks/__init__.py +++ b/python/hopsworks/__init__.py @@ -23,7 +23,7 @@ from pathlib import Path from hopsworks.client.exceptions import RestAPIError, ProjectException -from hopsworks import version, constants +from hopsworks import version, constants, client from hopsworks.connection import Connection # Needs to run before import of hsml and hsfs @@ -283,6 +283,7 @@ def _prompt_project(valid_connection, project): def logout(): global _hw_connection - if type(_hw_connection) is Connection: + if isinstance(_hw_connection, Connection): _hw_connection.close() + client.stop() _hw_connection = Connection.connection diff --git a/python/hopsworks/client/__init__.py b/python/hopsworks/client/__init__.py index 3bbd3d17b..1e4a7ea8f 100644 --- a/python/hopsworks/client/__init__.py +++ b/python/hopsworks/client/__init__.py @@ -67,5 +67,6 @@ def set_python_version(python_version): def stop(): global _client - _client._close() + if _client: + _client._close() _client = None diff --git a/python/hopsworks/connection.py b/python/hopsworks/connection.py index 02fa7c250..1fe984030 100644 --- a/python/hopsworks/connection.py +++ b/python/hopsworks/connection.py @@ -239,6 +239,7 @@ def connect(self): conn.connect() ``` """ + client.stop() self._connected = True try: # init client