From f13ea12c773f02f185f38990e6235d962a570bc2 Mon Sep 17 00:00:00 2001 From: Andrew Rowley Date: Wed, 11 Oct 2023 11:52:40 +0100 Subject: [PATCH 1/2] Allow missing bearer token to mean not in collab --- .../interface/abstract_spinnaker_base.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spinn_front_end_common/interface/abstract_spinnaker_base.py b/spinn_front_end_common/interface/abstract_spinnaker_base.py index dd7587a3c0..1790dd8f48 100644 --- a/spinn_front_end_common/interface/abstract_spinnaker_base.py +++ b/spinn_front_end_common/interface/abstract_spinnaker_base.py @@ -296,12 +296,16 @@ def __group_collab_or_job(self): cwd = os.getcwd() match_obj = SHARED_PATH.match(cwd) if match_obj: - return self.__get_collab_id_from_folder( + collab = self.__get_collab_id_from_folder( match_obj.group(SHARED_GROUP)) + if collab is not None: + return collab match_obj = SHARED_WITH_PATH.match(cwd) if match_obj: - return self.__get_collab_id_from_folder( + collab = self.__get_collab_id_from_folder( match_obj.group(SHARED_WITH_GROUP)) + if collab is not None: + return collab # Try to use the config to get a group group = get_config_str_or_none("Machine", "spalloc_group") @@ -315,6 +319,9 @@ def __get_collab_id_from_folder(self, folder): """ Currently hacky way to get the EBRAINS collab id from the drive folder, replicated from the NMPI collab template. """ + token = self.__bearer_token + if token is None: + return None ebrains_drive_client = ebrains_drive.connect(token=self.__bearer_token) repo_by_title = ebrains_drive_client.repos.get_repos_by_name(folder) if len(repo_by_title) != 1: From 33aa1be791f246550aaa1824016190cb10c6bb30 Mon Sep 17 00:00:00 2001 From: Andrew Rowley Date: Wed, 11 Oct 2023 14:28:17 +0100 Subject: [PATCH 2/2] Use the read token --- spinn_front_end_common/interface/abstract_spinnaker_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spinn_front_end_common/interface/abstract_spinnaker_base.py b/spinn_front_end_common/interface/abstract_spinnaker_base.py index 1790dd8f48..86bfb440f3 100644 --- a/spinn_front_end_common/interface/abstract_spinnaker_base.py +++ b/spinn_front_end_common/interface/abstract_spinnaker_base.py @@ -322,7 +322,7 @@ def __get_collab_id_from_folder(self, folder): token = self.__bearer_token if token is None: return None - ebrains_drive_client = ebrains_drive.connect(token=self.__bearer_token) + ebrains_drive_client = ebrains_drive.connect(token=token) repo_by_title = ebrains_drive_client.repos.get_repos_by_name(folder) if len(repo_by_title) != 1: logger.warning(f"The repository for collab {folder} could not be"