Skip to content

Commit

Permalink
removed str from Union[GPU_OPTION, str, None] typing in a bunch o…
Browse files Browse the repository at this point in the history
…f places
  • Loading branch information
telamonian committed Aug 24, 2024
1 parent 08c553f commit 2a1762c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 7 additions & 5 deletions comfy_cli/standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import requests

from comfy_cli.constants import OS, PROC
from comfy_cli.constants import GPU_OPTION, OS, PROC
from comfy_cli.typing import PathLike
from comfy_cli.utils import download_progress, get_os, get_proc
from comfy_cli.uv import DependencyCompiler
Expand Down Expand Up @@ -92,6 +92,8 @@ def FromTarball(fpath: PathLike, name: PathLike = "python"):

old_rpath = fpath.parent / old_name
rpath = fpath.parent / name
# clean the expanded destination
shutil.rmtree(rpath, ignore_errors=True)
shutil.move(old_rpath, rpath)
return StandalonePython(rpath=rpath)

Expand Down Expand Up @@ -138,25 +140,25 @@ def run_comfy_cli(self, *args: list[str]):
def install_comfy(self, *args: list[str], gpu_arg: str = "--nvidia"):
self.run_comfy_cli("--here", "--skip-prompt", "install", "--fast-deps", gpu_arg, *args)

def compile_comfy_deps(self, comfyDir: PathLike, gpu: str, outDir: Optional[PathLike] = None):
def compile_comfy_deps(self, comfyDir: PathLike, gpu: GPU_OPTION, outDir: Optional[PathLike] = None):
outDir = self.rpath if outDir is None else outDir

self.dep_comp = DependencyCompiler(cwd=comfyDir, executable=self.executable, gpu=gpu, outDir=outDir)
self.dep_comp.compile_comfy_deps()

def install_comfy_deps(self, comfyDir: PathLike, gpu: str, outDir: Optional[PathLike] = None):
def install_comfy_deps(self, comfyDir: PathLike, gpu: GPU_OPTION, outDir: Optional[PathLike] = None):
outDir = self.rpath if outDir is None else outDir

self.dep_comp = DependencyCompiler(cwd=comfyDir, executable=self.executable, gpu=gpu, outDir=outDir)
self.dep_comp.install_core_plus_ext()

def precache_comfy_deps(self, comfyDir: PathLike, gpu: str, outDir: Optional[PathLike] = None):
def precache_comfy_deps(self, comfyDir: PathLike, gpu: GPU_OPTION, outDir: Optional[PathLike] = None):
outDir = self.rpath if outDir is None else outDir

self.dep_comp = DependencyCompiler(cwd=comfyDir, executable=self.executable, gpu=gpu, outDir=outDir)
self.dep_comp.precache_comfy_deps()

def wheel_comfy_deps(self, comfyDir: PathLike, gpu: str, outDir: Optional[PathLike] = None):
def wheel_comfy_deps(self, comfyDir: PathLike, gpu: GPU_OPTION, outDir: Optional[PathLike] = None):
outDir = self.rpath if outDir is None else outDir

self.dep_comp = DependencyCompiler(cwd=comfyDir, executable=self.executable, gpu=gpu, outDir=outDir)
Expand Down
6 changes: 2 additions & 4 deletions comfy_cli/uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def Wheel(
return _check_call(cmd, cwd)

@staticmethod
def Resolve_Gpu(gpu: Union[GPU_OPTION, str, None]):
def Resolve_Gpu(gpu: Union[GPU_OPTION, None]):
if gpu is None:
try:
tver = metadata.version("torch")
Expand All @@ -277,16 +277,14 @@ def Resolve_Gpu(gpu: Union[GPU_OPTION, str, None]):
return None
except metadata.PackageNotFoundError:
return None
elif isinstance(gpu, str):
return GPU_OPTION[gpu.upper()]
else:
return gpu

def __init__(
self,
cwd: PathLike = ".",
executable: PathLike = sys.executable,
gpu: Union[GPU_OPTION, str, None] = None,
gpu: Union[GPU_OPTION, None] = None,
outDir: PathLike = ".",
outName: str = "requirements.compiled",
reqFilesCore: Optional[list[PathLike]] = None,
Expand Down

0 comments on commit 2a1762c

Please sign in to comment.