Skip to content

Commit

Permalink
Allowing picking of specific branch in --url/--manager-url option…
Browse files Browse the repository at this point in the history
…s for `comfy install` command (#147)

* add support for choosing specific branch to `--manager-url` option

* update help for `--manager-url` to include how to pick branch

* add support for picking specific branch to `--url` option

* fix type hinting of `execute` signature

* small cleanup of url/branch splitting code
  • Loading branch information
telamonian authored Aug 2, 2024
1 parent bf3a042 commit 293b96c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
14 changes: 12 additions & 2 deletions comfy_cli/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,19 @@ def entry(
@app.command(help="Download and install ComfyUI and ComfyUI-Manager")
@tracking.track_command()
def install(
url: Annotated[str, typer.Option(show_default=False)] = constants.COMFY_GITHUB_URL,
url: Annotated[
str,
typer.Option(
show_default=False,
help="url or local path pointing to the ComfyUI core git repo to be installed. A specific branch can optionally be specified using a setuptools-like syntax, eg https://foo.git@bar",
),
] = constants.COMFY_GITHUB_URL,
manager_url: Annotated[
str, typer.Option(show_default=False)
str,
typer.Option(
show_default=False,
help="url or local path pointing to the ComfyUI-Manager git repo to be installed. A specific branch can optionally be specified using a setuptools-like syntax, eg https://foo.git@bar",
),
] = constants.COMFY_MANAGER_GITHUB_URL,
restore: Annotated[
bool,
Expand Down
24 changes: 19 additions & 5 deletions comfy_cli/command/install.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from rich import print
import os
import platform
import subprocess
import sys

import typer
from rich import print
from typing import Optional

from comfy_cli import constants, ui, utils
from comfy_cli.command.custom_nodes.command import update_node_id_cache
Expand Down Expand Up @@ -163,7 +163,7 @@ def execute(
comfy_path: str,
restore: bool,
skip_manager: bool,
commit=None,
commit: Optional[str] = None,
gpu: constants.GPU_OPTION = None,
cuda_version: constants.CUDAVersion = constants.CUDAVersion.v12_1,
plat: constants.OS = None,
Expand All @@ -189,7 +189,14 @@ def execute(
os.makedirs(parent_path, exist_ok=True)

if not os.path.exists(repo_dir):
subprocess.run(["git", "clone", url, repo_dir], check=True)
if "@" in url:
# clone specific branch
url, branch = url.rsplit("@", 1)

subprocess.run(["git", "clone", "-b", branch, url, repo_dir], check=True)
else:
subprocess.run(["git", "clone", url, repo_dir], check=True)

elif not check_comfy_repo(repo_dir)[0]:
print(
f"[bold red]'{repo_dir}' already exists. But it is an invalid ComfyUI repository. Remove it and retry.[/bold red]"
Expand Down Expand Up @@ -226,7 +233,14 @@ def execute(
else:
print("\nInstalling ComfyUI-Manager..")

subprocess.run(["git", "clone", manager_url, manager_repo_dir], check=True)
if "@" in manager_url:
# clone specific branch
manager_url, manager_branch = manager_url.rsplit("@", 1)

subprocess.run(["git", "clone", "-b", manager_branch, manager_url, manager_repo_dir], check=True)
else:
subprocess.run(["git", "clone", manager_url, manager_repo_dir], check=True)

install_manager_dependencies(repo_dir)

update_node_id_cache()
Expand Down

0 comments on commit 293b96c

Please sign in to comment.