Skip to content

Commit

Permalink
Merge pull request #34 from higgsfield-ai/feat/specify-invoker-version
Browse files Browse the repository at this point in the history
add: specify invoker version if needed
  • Loading branch information
higgsfield authored Nov 8, 2023
2 parents f8f27eb + 04b3e80 commit 2be35af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
5 changes: 3 additions & 2 deletions higgsfield/internal/ci/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def decode_secrets(env: str):


@click.command("setup-nodes")
def setup_nodes():
@click.option('--invoker_tag', default="v0.0.1", help="Tag of the invoker binary to use")
def setup_nodes(invoker_tag: str = "v0.0.1"):
wd = wd_path()
app_config = AppConfig.from_path(wd)

Expand All @@ -74,7 +75,7 @@ def setup_nodes():

app_config.set_git_origin_url(project_path)

setup = Setup(app_config, project_path)
setup = Setup(app_config, project_path, invoker_tag)

try:
setup.create_ssh_key_file()
Expand Down
22 changes: 18 additions & 4 deletions higgsfield/internal/ci/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@


docker_install_script = '''/bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/arpanetus/1c1210b9e432a04dcfb494725a407a70/raw/5d47baa19b7100261a2368a43ace610528e0dfa2/install.sh)"'''
invoker_install_script = """wget https://github.com/ml-doom/invoker/releases/download/latest/invoker-latest-linux-amd64.tar.gz && \
tar -xvf invoker-latest-linux-amd64.tar.gz && \

def invoker_install_script(tag: str) -> str:
return f"""wget https://github.com/ml-doom/invoker/releases/download/{tag}/invoker-{tag}-linux-amd64.tar.gz && \
tar -xvf invoker-{tag}-linux-amd64.tar.gz && \
sudo mv invoker /usr/bin/invoker && \
rm invoker-latest-linux-amd64.tar.gz"""
rm invoker-{tag}-linux-amd64.tar.gz"""


def deploy_key_script(key: str, project_name: str, deploy_key_string: str):
Expand All @@ -32,18 +34,21 @@ class Setup:
path: str
deploy_key: str
project_path: Path
invoker_tag: str

def __init__(
self,
app_config: AppConfig,
project_path: Path,
invoker_tag: str,
):
self.app_config = app_config

if reason := self.app_config.is_valid() is not None:
raise ValueError(reason)

self.project_path = project_path
self.invoker_tag = invoker_tag

def create_ssh_key_file(self):
if self.app_config.key is None:
Expand Down Expand Up @@ -97,7 +102,7 @@ async def printer(thing):
print("\n\n\nINSTALLING INVOKER\n\n\n")
to_run = []
for conn in self.connections:
to_run.append(printer(await conn.run(invoker_install_script)))
to_run.append(printer(await conn.run(invoker_install_script(self.invoker_tag))))

await asyncio.gather(*to_run)

Expand All @@ -111,6 +116,15 @@ async def printer(thing):
to_run.append(printer(await conn.run(dk_script)))

await asyncio.gather(*to_run)

# close connections
for conn in self.connections:
conn.close()


# re-establish connections
await self.establish_connections()


print("\n\n\nPULLING BASE DOCKER IMAGE\n\n\n")
to_run = []
Expand Down

0 comments on commit 2be35af

Please sign in to comment.