8000 [Optional] Checkout specific commit for ComfyUI-Manager by robinjhuang · Pull Request #207 · Comfy-Org/comfy-cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Optional] Checkout specific commit for ComfyUI-Manager #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions comfy_cli/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ def install(
help="Use new fast dependency installer",
),
] = False,
manager_commit: Annotated[
Optional[str],
typer.Option(help="Specify commit hash for ComfyUI-Manager"),
] = None,
):
check_for_updates()
checker = EnvChecker()
Expand Down Expand Up @@ -279,6 +283,7 @@ def install(
skip_torch_or_directml=skip_torch_or_directml,
skip_requirement=skip_requirement,
fast_deps=fast_deps,
manager_commit=manager_commit,
)
rprint(f"ComfyUI is installed at: {comfy_path}")
return None
Expand Down Expand Up @@ -346,6 +351,7 @@ def install(
skip_torch_or_directml=skip_torch_or_directml,
skip_requirement=skip_requirement,
fast_deps=fast_deps,
manager_commit=manager_commit,
)

rprint(f"ComfyUI is installed at: {comfy_path}")
Expand Down
40 changes: 37 additions & 3 deletions comfy_cli/command/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def execute(
skip_manager: bool,
version: str,
commit: Optional[str] = None,
manager_commit: Optional[str] = None,
gpu: constants.GPU_OPTION = None,
cuda_version: constants.CUDAVersion = constants.CUDAVersion.v12_1,
plat: constants.OS = None,
Expand Down Expand Up @@ -188,13 +189,17 @@ def execute(
clone_comfyui(url=url, repo_dir=repo_dir)

if version != "nightly":
checkout_stable_comfyui(version=version, repo_dir=repo_dir)
try:
checkout_stable_comfyui(version=version, repo_dir=repo_dir)
except GitHubRateLimitError as e:
rprint(f"[bold red]Error checking out ComfyUI version: {e}[/bold red]")
sys.exit(1)

elif not check_comfy_repo(repo_dir)[0]:
rprint(
f"[bold red]'{repo_dir}' already exists. But it is an invalid ComfyUI repository. Remove it and retry.[/bold red]"
)
exit(-1)
sys.exit(-1)

# checkout specified commit
if commit is not None:
Expand Down Expand Up @@ -234,6 +239,8 @@ def execute(
)
else:
subprocess.run(["git", "clone", manager_url, manager_repo_dir], check=True)
if manager_commit is not None:
subprocess.run(["git", "checkout", manager_commit], check=True, cwd=manager_repo_dir)

if not fast_deps:
pip_install_manager_dependencies(repo_dir)
Expand Down Expand Up @@ -281,12 +288,39 @@ def validate_version(version: str) -> Optional[str]:
) from exc


class GitHubRateLimitError(Exception):
"""Raised when GitHub API rate limit is exceeded"""


def fetch_github_releases(repo_owner: str, repo_name: str) -> List[Dict[str, str]]:
"""
Fetch the list of releases from the GitHub API.
Handles rate limiting by logging the wait time.
"""
url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/releases"
response = requests.get(url)

headers = {}
if github_token := os.getenv("GITHUB_TOKEN"):
headers["Authorization"] = f"Bearer {github_token}"

response = requests.get(url, headers=headers, timeout=5)

# Handle rate limiting
if response.status_code in (403, 429):
# Check rate limit headers
remaining = int(response.headers.get("x-ratelimit-remaining", 0))
if remaining == 0:
reset_time = int(response.headers.get("x-ratelimit-reset", 0))
message = f"Primary rate limit from Github exceeded! Please retry after: {reset_time})"
raise GitHubRateLimitError(message)

if "retry-after" in response.headers:
wait_seconds = int(response.headers["retry-after"])
message = f"Rate limit from Github exceeded! Please wait {wait_seconds} seconds before retrying."
rprint(f"[yellow]{message}[/yellow]")
raise GitHubRateLimitError(message)

response.raise_for_status()
return response.json()


Expand Down
2 changes: 1 addition & 1 deletion tests/comfy_cli/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_fetch_releases_su 5E4B ccess(mock_get):
assert len(releases) == 2
assert releases[0]["tag_name"] == "v1.0.0"
assert releases[1]["tag_name"] == "v1.1.0"
mock_get.assert_called_once_with("https://api.github.com/repos/owner/repo/releases")
mock_get.assert_called_once_with("https://api.github.com/repos/owner/repo/releases", headers={}, timeout=5)


@patch("requests.get")
Expand Down
Loading
0