Skip to content

Commit

Permalink
Merge branch 'main' into dr-feat-cnr
Browse files Browse the repository at this point in the history
  • Loading branch information
ltdrdata committed Sep 6, 2024
2 parents 6150ea6 + f303c37 commit 40ba1ef
Show file tree
Hide file tree
Showing 15 changed files with 472 additions and 206 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/run-on-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ on:
paths:
- "comfy_cli/**"
- "!comfy_cli/test_**"
- "!.github/**"
pull_request:
branches:
- main
paths:
- "comfy_cli/**"
- "!comfy_cli/test_**"
- "!.github/**"

jobs:
test-cli-gpu:
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/test-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "Mac Specific Commands"
on:
pull_request:
branches:
- main

jobs:
test:
runs-on: macos-latest
env:
PYTHONIOENCODING: "utf8"

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install Dependencies
run: |
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install pytest
pip install -e .
comfy --skip-prompt --workspace ./ComfyUI install --fast-deps --m-series --skip-manager
comfy --workspace ./ComfyUI standalone --platform macos
comfy standalone --rehydrate
./python/bin/python ComfyUI/main.py --cpu --quick-test-for-ci
34 changes: 34 additions & 0 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Windows Specific Commands"
on:
pull_request:
branches:
- main

jobs:
test:
runs-on: windows-latest
env:
PYTHONIOENCODING: "utf8"

steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install Dependencies
run: |
python -m venv venv
.\venv\Scripts\Activate.ps1
Get-Command python
python -m pip install --upgrade pip
pip install pytest
pip install -e .
comfy --skip-prompt --workspace ./ComfyUI install --fast-deps --nvidia --cuda-version 12.1 --skip-manager
comfy --workspace ./ComfyUI standalone --platform windows --proc x86_64
ls
comfy standalone --rehydrate --platform windows --proc x86_64
./python/python.exe ComfyUI/main.py --cpu --quick-test-for-ci
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ __pycache__/

#COMMON CONFIGs
.DS_Store
.ruff_cache
.src_port
.webpack_watch.log
*.swp
Expand Down Expand Up @@ -48,9 +47,15 @@ share/python-wheels/
*.manifest
*.spec

# temporary files created by tests
# temporary files created by linting, tests, etc
.pytest_cache/
.ruff_cache/
tests/temp/

venv/

bisect_state.json
python*
cpython*
requirements.compiled
override.txt
96 changes: 18 additions & 78 deletions comfy_cli/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,14 @@ def install(
elif amd:
gpu = GPU_OPTION.AMD
elif m_series:
gpu = GPU_OPTION.M_SERIES
gpu = GPU_OPTION.MAC_M_SERIES
elif intel_arc:
gpu = GPU_OPTION.INTEL_ARC
else:
if platform == constants.OS.MACOS:
gpu = ui.prompt_select_enum(
"What type of Mac do you have?",
[GPU_OPTION.M_SERIES, GPU_OPTION.MAC_INTEL],
[GPU_OPTION.MAC_M_SERIES, GPU_OPTION.MAC_INTEL],
)
else:
gpu = ui.prompt_select_enum(
Expand Down Expand Up @@ -547,6 +547,13 @@ def feedback():
@app.command(help="Download a standalone Python interpreter and dependencies based on an existing comfyui workspace")
@tracking.track_command()
def standalone(
cli_spec: Annotated[
str,
typer.Option(
show_default=False,
help="setuptools-style requirement specificer pointing to an instance of comfy-cli",
),
] = "comfy-cli",
platform: Annotated[
Optional[constants.OS],
typer.Option(
Expand All @@ -561,93 +568,26 @@ def standalone(
help="Create standalone Python for specified processor",
),
] = None,
nvidia: Annotated[
Optional[bool],
typer.Option(
show_default=False,
help="Create standalone Python for Nvidia gpu",
callback=g_gpu_exclusivity.validate,
),
] = None,
cuda_version: Annotated[CUDAVersion, typer.Option(show_default=True)] = CUDAVersion.v12_1,
amd: Annotated[
Optional[bool],
typer.Option(
show_default=False,
help="Create standalone Python for AMD gpu",
callback=g_gpu_exclusivity.validate,
),
] = None,
m_series: Annotated[
Optional[bool],
typer.Option(
show_default=False,
help="Create standalone Python for Mac M-Series gpu",
callback=g_gpu_exclusivity.validate,
),
] = None,
intel_arc: Annotated[
Optional[bool],
typer.Option(
hidden=True,
show_default=False,
help="(Beta support) Create standalone Python for Intel Arc gpu, based on https://github.com/comfyanonymous/ComfyUI/pull/3439",
callback=g_gpu_exclusivity.validate,
),
] = None,
cpu: Annotated[
Optional[bool],
rehydrate: Annotated[
bool,
typer.Option(
show_default=False,
help="Create standalone Python for CPU",
callback=g_gpu_exclusivity.validate,
),
] = None,
] = False,
):
comfy_path, _ = workspace_manager.get_workspace_path()

platform = utils.get_os() if platform is None else platform
proc = utils.get_proc() if proc is None else proc

if cpu:
gpu = GPU_OPTION.CPU
elif nvidia:
gpu = GPU_OPTION.NVIDIA
elif amd:
gpu = GPU_OPTION.AMD
elif m_series:
gpu = GPU_OPTION.M_SERIES
elif intel_arc:
gpu = GPU_OPTION.INTEL_ARC
if rehydrate:
sty = StandalonePython.FromTarball(fpath="python.tgz")
sty.rehydrate_comfy_deps()
else:
if platform == constants.OS.MACOS:
gpu = ui.prompt_select_enum(
"What type of Mac do you have?",
[GPU_OPTION.M_SERIES, GPU_OPTION.MAC_INTEL],
)
else:
gpu = ui.prompt_select_enum(
"What GPU do you have?",
[GPU_OPTION.NVIDIA, GPU_OPTION.AMD, GPU_OPTION.INTEL_ARC, GPU_OPTION.CPU],
)

if gpu == GPU_OPTION.INTEL_ARC:
print("[bold yellow]Installing on Intel ARC is not yet completely supported[/bold yellow]")
env_check = env_checker.EnvChecker()
if env_check.conda_env is None:
print("[bold red]Intel ARC support requires conda environment to be activated.[/bold red]")
raise typer.Exit(code=1)
if intel_arc is None:
confirm_result = ui.prompt_confirm_action(
"Are you sure you want to try beta install feature on Intel ARC?", True
)
if not confirm_result:
raise typer.Exit(code=0)
print("[bold yellow]Installing on Intel ARC is in beta stage.[/bold yellow]")

sty = StandalonePython.FromDistro(platform=platform, proc=proc)
sty.precache_comfy_deps(comfyDir=comfy_path, gpu=gpu)
sty.to_tarball()
sty = StandalonePython.FromDistro(platform=platform, proc=proc)
sty.dehydrate_comfy_deps(comfyDir=comfy_path, extraSpecs=cli_spec)
sty.to_tarball()


app.add_typer(models_command.app, name="model", help="Manage models.")
Expand Down
3 changes: 2 additions & 1 deletion comfy_cli/command/custom_nodes/cm_cli_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def execute_cm_cli(args, channel=None, fast_deps=False, mode=None) -> str | None
if fast_deps and args[0] in _dependency_cmds:
# we're using the fast_deps behavior and just ran a command that invalidated the dependencies
depComp = DependencyCompiler(cwd=workspace_path)
depComp.install_comfy_deps()
depComp.compile_deps()
depComp.install_deps()

return result.stdout
except subprocess.CalledProcessError as e:
Expand Down
5 changes: 3 additions & 2 deletions comfy_cli/command/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def pip_install_comfyui_dependencies(
result = subprocess.run([sys.executable, "-m", "pip", "install", "torch-directml"], check=True)

# install torch for Mac M Series
if gpu == GPU_OPTION.M_SERIES:
if gpu == GPU_OPTION.MAC_M_SERIES:
result = subprocess.run(
[
sys.executable,
Expand Down Expand Up @@ -231,7 +231,8 @@ def execute(

if fast_deps:
depComp = DependencyCompiler(cwd=repo_dir, gpu=gpu)
depComp.install_comfy_deps()
depComp.compile_deps()
depComp.install_deps()

if not skip_manager:
update_node_id_cache()
Expand Down
2 changes: 1 addition & 1 deletion comfy_cli/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class GPU_OPTION(str, Enum):
NVIDIA = "nvidia"
AMD = "amd"
INTEL_ARC = "intel_arc"
M_SERIES = "mac_m_series"
MAC_M_SERIES = "mac_m_series"
MAC_INTEL = "mac_intel"


Expand Down
Loading

0 comments on commit 40ba1ef

Please sign in to comment.