Skip to content
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
8 changes: 4 additions & 4 deletions .github/.codecov.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
codecov:
allow_coverage_offsets: true # Avoid "Missing base report" due to committing with "[CI skip]"

comment:
require_changes: true
layout: "diff, files"

coverage:
status:
project:
default:
target: auto
threshold: 1%
patch: off
threshold: 0.5%
3 changes: 2 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ jobs:
pytest --cov=comfy_cli --cov-report=xml .

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
(^.*\.(json|txt)$)

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
rev: v0.12.4
hooks:
# Run the linter.
- id: ruff
Expand Down
5 changes: 2 additions & 3 deletions comfy_cli/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
import subprocess
import sys
import webbrowser
from typing import Optional
from typing import Annotated, Optional

import questionary
import typer
from rich import print as rprint
from rich.console import Console
from typing_extensions import Annotated, List

from comfy_cli import constants, env_checker, logging, tracking, ui, utils
from comfy_cli.command import custom_nodes
Expand Down Expand Up @@ -487,7 +486,7 @@ def stop():
@tracking.track_command()
def launch(
background: Annotated[bool, typer.Option(help="Launch ComfyUI in background")] = False,
extra: List[str] = typer.Argument(None),
extra: list[str] = typer.Argument(None),
):
launch_command(background, extra)

Expand Down
3 changes: 1 addition & 2 deletions comfy_cli/command/custom_nodes/bisect_custom_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import json
import os
from pathlib import Path
from typing import Literal, NamedTuple
from typing import Annotated, Literal, NamedTuple

import typer
from typing_extensions import Annotated

from comfy_cli.command.custom_nodes.cm_cli_util import execute_cm_cli
from comfy_cli.command.launch import launch as launch_command
Expand Down
23 changes: 11 additions & 12 deletions comfy_cli/command/custom_nodes/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import subprocess
import sys
import uuid
from typing import Optional
from typing import Annotated, Optional

import typer
from rich import print
from rich.console import Console
from typing_extensions import Annotated, List

from comfy_cli import logging, tracking, ui, utils
from comfy_cli.command.custom_nodes.bisect_custom_nodes import bisect_app
Expand Down Expand Up @@ -151,7 +150,7 @@ def execute_install_script(repo_path):
# import pdb
# pdb.set_trace()
print("Install: pip packages")
with open(requirements_path, "r", encoding="utf-8") as requirements_file:
with open(requirements_path, encoding="utf-8") as requirements_file:
for line in requirements_file:
# From Yoland: disable pip override
# package_name = remap_pip_package(line.strip())
Expand Down Expand Up @@ -269,7 +268,7 @@ def node_completer(incomplete: str) -> list[str]:
config_manager = ConfigManager()
tmp_path = os.path.join(config_manager.get_config_path(), "tmp", "node-cache.list")

with open(tmp_path, "r", encoding="UTF-8", errors="ignore") as cache_file:
with open(tmp_path, encoding="UTF-8", errors="ignore") as cache_file:
return [node_id for node_id in cache_file.readlines() if node_id.startswith(incomplete)]

except Exception:
Expand All @@ -285,7 +284,7 @@ def node_or_all_completer(incomplete: str) -> list[str]:
if "all".startswith(incomplete):
all_opt = ["all"]

with open(tmp_path, "r", encoding="UTF-8", errors="ignore") as cache_file:
with open(tmp_path, encoding="UTF-8", errors="ignore") as cache_file:
return [node_id for node_id in cache_file.readlines() if node_id.startswith(incomplete)] + all_opt

except Exception:
Expand Down Expand Up @@ -384,7 +383,7 @@ def simple_show(
@app.command(help="Install custom nodes")
@tracking.track_command("node")
def install(
nodes: List[str] = typer.Argument(..., help="List of custom nodes to install", autocompletion=node_completer),
nodes: list[str] = typer.Argument(..., help="List of custom nodes to install", autocompletion=node_completer),
channel: Annotated[
Optional[str],
typer.Option(
Expand Down Expand Up @@ -431,7 +430,7 @@ def install(
@app.command(help="Reinstall custom nodes")
@tracking.track_command("node")
def reinstall(
nodes: List[str] = typer.Argument(..., help="List of custom nodes to reinstall", autocompletion=node_completer),
nodes: list[str] = typer.Argument(..., help="List of custom nodes to reinstall", autocompletion=node_completer),
channel: Annotated[
Optional[str],
typer.Option(
Expand Down Expand Up @@ -466,7 +465,7 @@ def reinstall(
@app.command(help="Uninstall custom nodes")
@tracking.track_command("node")
def uninstall(
nodes: List[str] = typer.Argument(..., help="List of custom nodes to uninstall", autocompletion=node_completer),
nodes: list[str] = typer.Argument(..., help="List of custom nodes to uninstall", autocompletion=node_completer),
channel: Annotated[
Optional[str],
typer.Option(
Expand Down Expand Up @@ -512,7 +511,7 @@ def update_node_id_cache():
@app.command(help="Update custom nodes or ComfyUI")
@tracking.track_command("node")
def update(
nodes: List[str] = typer.Argument(
nodes: list[str] = typer.Argument(
...,
help="[all|List of custom nodes to update]",
autocompletion=node_or_all_completer,
Expand Down Expand Up @@ -541,7 +540,7 @@ def update(
@app.command(help="Disable custom nodes")
@tracking.track_command("node")
def disable(
nodes: List[str] = typer.Argument(
nodes: list[str] = typer.Argument(
...,
help="[all|List of custom nodes to disable]",
autocompletion=node_or_all_completer,
Expand All @@ -568,7 +567,7 @@ def disable(
@app.command(help="Enable custom nodes")
@tracking.track_command("node")
def enable(
nodes: List[str] = typer.Argument(
nodes: list[str] = typer.Argument(
...,
help="[all|List of custom nodes to enable]",
autocompletion=node_or_all_completer,
Expand All @@ -595,7 +594,7 @@ def enable(
@app.command(help="Fix dependencies of custom nodes")
@tracking.track_command("node")
def fix(
nodes: List[str] = typer.Argument(
nodes: list[str] = typer.Argument(
...,
help="[all|List of custom nodes to fix]",
autocompletion=node_or_all_completer,
Expand Down
10 changes: 5 additions & 5 deletions comfy_cli/command/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import platform
import subprocess
import sys
from typing import Dict, List, Optional, TypedDict
from typing import Optional, TypedDict
from urllib.parse import urlparse

import requests
Expand Down Expand Up @@ -389,7 +389,7 @@ def handle_github_rate_limit(response):
raise GitHubRateLimitError(message)


def fetch_github_releases(repo_owner: str, repo_name: str) -> List[Dict[str, str]]:
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.
Expand Down Expand Up @@ -425,11 +425,11 @@ class GithubRelease(TypedDict):
download_url: str


def parse_releases(releases: List[Dict[str, str]]) -> List[GithubRelease]:
def parse_releases(releases: list[dict[str, str]]) -> list[GithubRelease]:
"""
Parse the list of releases fetched from the GitHub API into a list of GithubRelease objects.
"""
parsed_releases: List[GithubRelease] = []
parsed_releases: list[GithubRelease] = []
for release in releases:
tag = release["tag_name"]
if tag.lower() in ["latest", "nightly"]:
Expand All @@ -441,7 +441,7 @@ def parse_releases(releases: List[Dict[str, str]]) -> List[GithubRelease]:
return parsed_releases


def select_version(releases: List[GithubRelease], version: str) -> Optional[GithubRelease]:
def select_version(releases: list[GithubRelease], version: str) -> Optional[GithubRelease]:
"""
Given a list of Github releases, select the release that matches the specified version.
"""
Expand Down
9 changes: 4 additions & 5 deletions comfy_cli/command/models/models.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import os
import pathlib
import sys
from typing import List, Optional, Tuple
from typing import Annotated, Optional
from urllib.parse import unquote, urlparse

import requests
import typer
from rich import print
from typing_extensions import Annotated

from comfy_cli import constants, tracking, ui
from comfy_cli.config_manager import ConfigManager
Expand Down Expand Up @@ -39,7 +38,7 @@ def potentially_strip_param_url(path_name: str) -> str:
return path_name


def check_huggingface_url(url: str) -> Tuple[bool, Optional[str], Optional[str], Optional[str], Optional[str]]:
def check_huggingface_url(url: str) -> tuple[bool, Optional[str], Optional[str], Optional[str], Optional[str]]:
"""
Check if the given URL is a Hugging Face URL and extract relevant information.

Expand Down Expand Up @@ -76,7 +75,7 @@ def check_huggingface_url(url: str) -> Tuple[bool, Optional[str], Optional[str],
return True, repo_id, filename, folder_name, branch_name


def check_civitai_url(url: str) -> Tuple[bool, bool, int, int]:
def check_civitai_url(url: str) -> tuple[bool, bool, int, int]:
"""
Returns:
is_civitai_model_url: True if the url is a civitai model url
Expand Down Expand Up @@ -314,7 +313,7 @@ def remove(
help="The relative path from the current workspace where the models are stored.",
show_default=True,
),
model_names: Optional[List[str]] = typer.Option(
model_names: Optional[list[str]] = typer.Option(
None,
help="List of model filenames to delete, separated by spaces",
show_default=False,
Expand Down
2 changes: 1 addition & 1 deletion comfy_cli/command/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def get_renderables(self):
)

for task in self.tasks:
percent = "[progress.percentage]{task.percentage:>3.0f}%".format(task=task)
percent = "[progress.percentage]{task.percentage:>3.0f}%".format(task=task) # noqa
if task.fields.get("progress_type") == "overall":
overall_table = Table.grid(*table_columns, padding=(0, 1), expand=self.expand)
overall_table.add_row(BarColumn().render(task), percent, TimeElapsedColumn().render(task))
Expand Down
6 changes: 3 additions & 3 deletions comfy_cli/config_manager.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import configparser
import os
from importlib.metadata import version
from typing import Optional, Tuple
from typing import Optional

from comfy_cli import constants, logging
from comfy_cli.utils import get_os, is_running, singleton


@singleton
class ConfigManager(object):
class ConfigManager:
def __init__(self):
self.config = configparser.ConfigParser()
self.background: Optional[Tuple[str, int, int]] = None
self.background: Optional[tuple[str, int, int]] = None
self.load()

@staticmethod
Expand Down
6 changes: 3 additions & 3 deletions comfy_cli/env_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def format_python_version(version_info):
str: The formatted Python version string.
"""
if version_info.major == 3 and version_info.minor > 8:
return "{}.{}.{}".format(version_info.major, version_info.minor, version_info.micro)
return "[bold red]{}.{}.{}[/bold red]".format(version_info.major, version_info.minor, version_info.micro)
return f"{version_info.major}.{version_info.minor}.{version_info.micro}"
return f"[bold red]{version_info.major}.{version_info.minor}.{version_info.micro}[/bold red]"


def check_comfy_server_running(port=8188, host="localhost"):
Expand All @@ -47,7 +47,7 @@ def check_comfy_server_running(port=8188, host="localhost"):


@singleton
class EnvChecker(object):
class EnvChecker:
"""
Provides an `EnvChecker` class to check the current environment and print information about it.

Expand Down
12 changes: 6 additions & 6 deletions comfy_cli/registry/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def create_comfynode_config():
try:
with open("pyproject.toml", "w") as toml_file:
toml_file.write(tomlkit.dumps(document))
except IOError as e:
except OSError as e:
raise Exception("Failed to write 'pyproject.toml'") from e


Expand Down Expand Up @@ -166,7 +166,7 @@ def validate_version(version: str, field_name: str) -> str:
def initialize_project_config():
create_comfynode_config()

with open("pyproject.toml", "r") as file:
with open("pyproject.toml") as file:
document = tomlkit.parse(file.read())

# Get the current git remote URL
Expand Down Expand Up @@ -237,7 +237,7 @@ def initialize_project_config():

# Handle dependencies
if os.path.exists("requirements.txt"):
with open("requirements.txt", "r") as req_file:
with open("requirements.txt") as req_file:
dependencies = [line.strip() for line in req_file if line.strip()]
project["dependencies"] = dependencies
else:
Expand All @@ -248,8 +248,8 @@ def initialize_project_config():
with open("pyproject.toml", "w") as toml_file:
toml_file.write(tomlkit.dumps(document))
print("pyproject.toml has been created successfully in the current directory.")
except IOError as e:
raise IOError("Failed to write 'pyproject.toml'") from e
except OSError as e:
raise OSError("Failed to write 'pyproject.toml'") from e


def extract_node_configuration(
Expand All @@ -259,7 +259,7 @@ def extract_node_configuration(
ui.display_error_message("No pyproject.toml file found in the current directory.")
return None

with open(path, "r") as file:
with open(path) as file:
data = tomlkit.load(file)

project_data = data.get("project", {})
Expand Down
Loading
Loading