Skip to content

Commit

Permalink
build exec conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
agahkarakuzu committed Nov 5, 2024
1 parent 67e6f42 commit 6cc92ba
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions myst_libre/builders/myst_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,33 @@
from myst_libre.abstract_class import AbstractClass

class MystBuilder(AbstractClass):
def __init__(self, hub):
if not isinstance(hub, JupyterHubLocalSpawner):
raise TypeError(f"Expected 'hub' to be an instance of JupyterHubLocalSpawner, got {type(hub).__name__} instead")
def __init__(self, hub=None, build_dir=None):
if hub is not None:
if not isinstance(hub, JupyterHubLocalSpawner):
raise TypeError(f"Expected 'hub' to be an instance of JupyterHubLocalSpawner, got {type(hub).__name__} instead")
self.hub = hub
self.env_vars = {
"JUPYTER_BASE_URL": f"{self.hub.jh_url}",
"JUPYTER_TOKEN": f"{self.hub.jh_token}",
"port": f"{self.hub.port}"
}
self.build_dir = self.hub.rees.build_dir
else:
if build_dir is None:
raise ValueError("If 'hub' is None, 'build_dir' must be provided")
self.build_dir = build_dir
self.env_vars = {}
self.hub = None

super().__init__()
self.env_vars = {}
self.build_dir = ""
self.hub = hub
self.env_vars = {"JUPYTER_BASE_URL":f"{self.hub.jh_url}",
"JUPYTER_TOKEN":f"{self.hub.jh_token}",
"port":f"{self.hub.port}"
}
self.myst_client = MystMD(hub.rees.build_dir, self.env_vars)
self.myst_client = MystMD(self.build_dir, self.env_vars)

def setenv(self,key,value):
self.env_vars[key] = value

def build(self,*args):
self.cprint(f'Starting MyST build {self.hub.jh_url}','yellow')
if self.hub is not None:
self.cprint(f'Starting MyST build {self.hub.jh_url}','yellow')
else:
self.cprint(f'Starting MyST build no exec.','yellow')
self.myst_client.build('build',*args)

0 comments on commit 6cc92ba

Please sign in to comment.