From 04a2045269c209f2df3adaa70c7ffa2cb61b75eb Mon Sep 17 00:00:00 2001 From: Komal Thareja Date: Wed, 23 Oct 2024 17:01:24 -0400 Subject: [PATCH 1/3] disable refresh on SliceManager instantiation - token is refreshed when used --- fabrictestbed/__init__.py | 2 +- fabrictestbed/token_manager/token_manager.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fabrictestbed/__init__.py b/fabrictestbed/__init__.py index 0e55b07..79639ee 100644 --- a/fabrictestbed/__init__.py +++ b/fabrictestbed/__init__.py @@ -1,2 +1,2 @@ -__version__ = "1.7.8" +__version__ = "1.7.9" __VERSION__ = __version__ diff --git a/fabrictestbed/token_manager/token_manager.py b/fabrictestbed/token_manager/token_manager.py index d0b49e7..1c20f61 100644 --- a/fabrictestbed/token_manager/token_manager.py +++ b/fabrictestbed/token_manager/token_manager.py @@ -113,7 +113,7 @@ def initialize(self): - Refresh if needed """ if not self.initialized: - self._load_tokens() + self._load_tokens(refresh=False) self.initialized = True def _check_initialized(self): From 36ee7505eae27949db0c96899d2341f64db769cf Mon Sep 17 00:00:00 2001 From: Komal Thareja Date: Wed, 23 Oct 2024 17:12:27 -0400 Subject: [PATCH 2/3] expose get project name --- fabrictestbed/token_manager/token_manager.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fabrictestbed/token_manager/token_manager.py b/fabrictestbed/token_manager/token_manager.py index 1c20f61..888e3f0 100644 --- a/fabrictestbed/token_manager/token_manager.py +++ b/fabrictestbed/token_manager/token_manager.py @@ -339,3 +339,17 @@ def get_user_email(self) -> str: if not self.user_email and self.get_id_token() and self.cm_proxy: self._extract_project_and_user_info_from_token(cm_host=self.cm_proxy.host) return self.user_email + + def get_project_name(self) -> str: + """ + Retrieve the project name associated with the current session. + + This method returns the project name if it has already been determined. If the project name + has not been set and an identity token is available, it will attempt to extract + the project name by decoding the token using the credential manager proxy. + + @return: The project_name if available; otherwise, None. + """ + if not self.project_name and self.get_id_token() and self.cm_proxy: + self._extract_project_and_user_info_from_token(cm_host=self.cm_proxy.host) + return self.project_name From 27cffcd4536900ff0b42f08ee82bb5a810bd1c7a Mon Sep 17 00:00:00 2001 From: Komal Thareja Date: Fri, 1 Nov 2024 09:26:30 -0400 Subject: [PATCH 3/3] undo disable refresh change on start --- fabrictestbed/token_manager/token_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabrictestbed/token_manager/token_manager.py b/fabrictestbed/token_manager/token_manager.py index 888e3f0..d5dc58f 100644 --- a/fabrictestbed/token_manager/token_manager.py +++ b/fabrictestbed/token_manager/token_manager.py @@ -113,7 +113,7 @@ def initialize(self): - Refresh if needed """ if not self.initialized: - self._load_tokens(refresh=False) + self._load_tokens() self.initialized = True def _check_initialized(self):