From 4f15b7eb0a6181f50f1841f8a49172afb90616f3 Mon Sep 17 00:00:00 2001 From: Agah Date: Sat, 14 Sep 2024 00:19:00 -0400 Subject: [PATCH] Jupyterbook build entrypoint --- myst_libre/tools/jupyter_hub_local_spawner.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/myst_libre/tools/jupyter_hub_local_spawner.py b/myst_libre/tools/jupyter_hub_local_spawner.py index 08ddbb6..4cb27e1 100644 --- a/myst_libre/tools/jupyter_hub_local_spawner.py +++ b/myst_libre/tools/jupyter_hub_local_spawner.py @@ -68,7 +68,7 @@ def _is_port_in_use(self, port): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: return s.connect_ex(('127.0.0.1', port)) == 0 - def spawn_jupyter_hub(self): + def spawn_jupyter_hub(self,jb_build_command=None): """ Spawn a JupyterHub instance. """ @@ -77,6 +77,11 @@ def spawn_jupyter_hub(self): h.update(os.urandom(20)) self.jh_token = h.hexdigest() + if jb_build_command: + this_entrypoint = f"jupyter-book build --all --verbose --path-output {self.host_build_source_parent_dir} content 2>&1 | tee -a jupyter_book_build.log" + else: + this_entrypoint = f'jupyter server --allow-root --ip 0.0.0.0 --log-level=DEBUG --IdentityProvider.token="{self.jh_token}" --ServerApp.port="{self.port}"' + if not self.rees.search_img_by_repo_name(): raise Exception(f"[ERROR] A docker image has not been found for {self.rees.gh_user_repo_name} at {self.rees.binder_image_tag}.") if self.rees.binder_image_tag not in self.rees.found_image_tags: @@ -103,7 +108,7 @@ def spawn_jupyter_hub(self): self.rees.docker_image, ports={f'{self.port}/tcp': self.port}, environment={"JUPYTER_TOKEN": f'{self.jh_token}',"port": f'{self.port}',"JUPYTER_BASE_URL": f'{self.jh_url}'}, - entrypoint=f'jupyter server --allow-root --ip 0.0.0.0 --log-level=DEBUG --IdentityProvider.token="{self.jh_token}" --ServerApp.port="{self.port}"', + entrypoint= this_entrypoint, volumes=mnt_vol, detach=True) logging.info(f'Jupyter hub is {self.container.status}')