From 3e6403bce767af3898fa0e088f249273aff92f24 Mon Sep 17 00:00:00 2001 From: Agah Date: Mon, 25 Nov 2024 16:25:30 -0500 Subject: [PATCH] Fix existing repo logic --- myst_libre/tools/build_source_manager.py | 12 +++++++----- myst_libre/tools/jupyter_hub_local_spawner.py | 5 ++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/myst_libre/tools/build_source_manager.py b/myst_libre/tools/build_source_manager.py index a91281d..7f15b3b 100644 --- a/myst_libre/tools/build_source_manager.py +++ b/myst_libre/tools/build_source_manager.py @@ -39,7 +39,7 @@ def create_build_dir_host(self): bool: True if directory created, else False. """ if not os.path.exists(self.build_dir): - os.makedirs(self.build_dir) + os.makedirs(self.build_dir, exist_ok=True) return True return False @@ -52,12 +52,14 @@ def git_clone_repo(self,clone_parent_directory): """ self.host_build_source_parent_dir = clone_parent_directory self.build_dir = os.path.join(self.host_build_source_parent_dir, self.username, self.repo_name, self.gh_repo_commit_hash) - if self.create_build_dir_host(): - self.cprint(f'Cloning into {self.build_dir}', "green") - self.repo_object = Repo.clone_from(f'{self.provider}/{self.gh_user_repo_name}', self.build_dir) - else: + + if os.path.exists(self.build_dir): self.cprint(f'Source {self.build_dir} already exists.', "yellow") self.repo_object = Repo(self.build_dir) + else: + os.makedirs(os.path.dirname(self.build_dir), exist_ok=True) + self.cprint(f'Cloning into {self.build_dir}', "green") + self.repo_object = Repo.clone_from(f'{self.provider}/{self.gh_user_repo_name}', self.build_dir) self.set_commit_info() self.validate_commits() diff --git a/myst_libre/tools/jupyter_hub_local_spawner.py b/myst_libre/tools/jupyter_hub_local_spawner.py index abb2a1f..d00256f 100644 --- a/myst_libre/tools/jupyter_hub_local_spawner.py +++ b/myst_libre/tools/jupyter_hub_local_spawner.py @@ -128,7 +128,10 @@ def spawn_jupyter_hub(self,jb_build_command=None): self.cprint(f' ├───────── ✸ {self.rees.pull_image_name}','light_blue') self.cprint(f' ├───────── ⎌ {self.rees.binder_image_tag}','light_blue') self.cprint(f" ├───────── ⏲ {self.rees.binder_commit_info['datetime']}: {self.rees.binder_commit_info['message']}".replace('\n', ''),'light_blue') - self.cprint(f' └───────── ℹ This image was built from REES-compliant {self.rees.gh_user_repo_name} repository at the commit above','yellow') + if self.rees.binder_image_name: + self.cprint(f' └───────── ℹ Using NeuroLibre base image {self.rees.binder_image_name}','yellow') + else: + self.cprint(f' └───────── ℹ This image was built from REES-compliant {self.rees.gh_user_repo_name} repository at the commit above','yellow') except Exception as e: logging.error(f'Could not spawn a JH: \n {e}')