@@ -86,7 +86,7 @@ def init(dir: str, verbose: int):
8686 capture_output = True ,
8787 )
8888 except (subprocess .SubprocessError , FileNotFoundError ):
89- console .print ("[red]Error: git is not installed or not in PATH[/red]" )
89+ rich .print ("[red]Error: git is not installed or not in PATH[/red]" )
9090 return 1
9191
9292 # Check if we have write permissions
@@ -97,36 +97,36 @@ def init(dir: str, verbose: int):
9797 test_file .touch ()
9898 test_file .unlink ()
9999 except (OSError , PermissionError ) as e :
100- console .print (f"[red]Error: No write permission in { dir } - { str (e )} [/red]" )
100+ rich .print (f"[red]Error: No write permission in { dir } - { str (e )} [/red]" )
101101 return 1
102102
103103 # Check if Python version is compatible
104104 if sys .version_info < (3 , 8 ):
105- console .print ("[red]Error: Python 3.8 or higher is required[/red]" )
105+ rich .print ("[red]Error: Python 3.8 or higher is required[/red]" )
106106 return 1
107107
108108 # Check if uv is installed
109109 try :
110110 _ensure_uv ()
111111 except RuntimeError as e :
112- console .print (f"[red]Error: { str (e )} [/red]" )
112+ rich .print (f"[red]Error: { str (e )} [/red]" )
113113 return 1
114114
115115 # Check if enough disk space is available (rough estimate: 2GB)
116116 try :
117117 free_space = shutil .disk_usage (install_dir ).free
118118 if free_space < 2 * 1024 * 1024 * 1024 : # 2GB in bytes
119- console .print (
119+ rich .print (
120120 "[yellow]Warning: Less than 2GB free disk space available[/yellow]"
121121 )
122122 except Exception as e :
123- console .print (
123+ rich .print (
124124 f"[yellow]Warning: Could not check free disk space - { str (e )} [/yellow]"
125125 )
126126
127127 # Clone ComfyUI if not exists
128128 if not (install_dir / ".git" ).exists ():
129- console .print ("[green]Cloning ComfyUI...[/green]" )
129+ rich .print ("[green]Cloning ComfyUI...[/green]" )
130130 subprocess .run (
131131 [
132132 "git" ,
@@ -138,7 +138,7 @@ def init(dir: str, verbose: int):
138138 )
139139
140140 # Update ComfyUI
141- console .print ("[green]Updating ComfyUI...[/green]" )
141+ rich .print ("[green]Updating ComfyUI...[/green]" )
142142 subprocess .run (
143143 ["git" , "pull" ],
144144 cwd = install_dir ,
@@ -147,7 +147,7 @@ def init(dir: str, verbose: int):
147147
148148 # Create and activate venv
149149 venv_dir = install_dir / ".venv"
150- console .print ("[green]Creating virtual environment with uv...[/green]" )
150+ rich .print ("[green]Creating virtual environment with uv...[/green]" )
151151 if venv_dir .exists ():
152152 shutil .rmtree (venv_dir )
153153 subprocess .run (
@@ -163,7 +163,7 @@ def init(dir: str, verbose: int):
163163 python = str (venv_dir / "bin" / "python" )
164164
165165 # Install requirements with uv
166- console .print ("[green]Installing ComfyUI requirements with uv...[/green]" )
166+ rich .print ("[green]Installing ComfyUI requirements with uv...[/green]" )
167167 subprocess .run (
168168 ["uv" , "pip" , "install" , "pip" , "--upgrade" ],
169169 env = {
@@ -182,7 +182,7 @@ def init(dir: str, verbose: int):
182182 )
183183
184184 # Install comfy-pack as custom node
185- console .print ("[green]Installing comfy-pack custom nodes...[/green]" )
185+ rich .print ("[green]Installing comfy-pack custom nodes...[/green]" )
186186 custom_nodes_dir = install_dir / "custom_nodes"
187187 custom_nodes_dir .mkdir (exist_ok = True )
188188
@@ -224,12 +224,12 @@ def init(dir: str, verbose: int):
224224 )
225225
226226 version = get_self_git_commit () or "unknown"
227- console .print (
227+ rich .print (
228228 f"\n [green]✓ Installation completed! (comfy-pack version: { version } )[/green]"
229229 )
230- console .print (f"ComfyUI directory: { install_dir } " )
230+ rich .print (f"ComfyUI directory: { install_dir } " )
231231
232- console .print (
232+ rich .print (
233233 "\n [green]Next steps:[/green]\n "
234234 f"1. cd { dir } \n "
235235 "2. source .venv/bin/activate # On Windows: .venv\\ Scripts\\ activate\n "
@@ -274,13 +274,20 @@ def init(dir: str, verbose: int):
274274 count = True ,
275275 help = "Increase verbosity level (use multiple times for more verbosity)" ,
276276)
277+ @click .option (
278+ "--preheat" ,
279+ is_flag = True ,
280+ help = "Preheat the workspace after unpacking" ,
281+ default = False ,
282+ )
277283def unpack_cmd (
278284 cpack : str ,
279285 dir : str ,
280286 include_disabled_models : bool ,
281287 no_models : bool ,
282288 no_venv : bool ,
283289 verbose : int ,
290+ preheat : bool ,
284291):
285292 import rich
286293
@@ -293,6 +300,7 @@ def unpack_cmd(
293300 all_models = include_disabled_models ,
294301 prepare_models = not no_models ,
295302 no_venv = no_venv ,
303+ preheat = preheat ,
296304 )
297305 rich .print ("\n [green]✓ ComfyUI Workspace is restored![/green]" )
298306 rich .print (f"{ dir } " )
@@ -406,19 +414,19 @@ def run(ctx, cpack: str, output_dir: str, help: bool, verbose: int):
406414
407415 workspace = _get_cache_workspace (cpack )
408416 if not (workspace / "DONE" ).exists ():
409- console .print ("\n [green]✓ Restoring ComfyUI Workspace...[/green]" )
417+ rich .print ("\n [green]✓ Restoring ComfyUI Workspace...[/green]" )
410418 if workspace .exists ():
411419 shutil .rmtree (workspace )
412420 install (cpack , workspace , verbose = verbose )
413421 with open (workspace / "DONE" , "w" ) as f :
414422 f .write ("DONE" )
415- console .print ("\n [green]✓ ComfyUI Workspace is restored![/green]" )
416- console .print (f"{ workspace } " )
423+ rich .print ("\n [green]✓ ComfyUI Workspace is restored![/green]" )
424+ rich .print (f"{ workspace } " )
417425
418426 from .run import ComfyUIServer , run_workflow
419427
420428 with ComfyUIServer (str (workspace .absolute ()), verbose = verbose ) as server :
421- console .print ("\n [green]✓ ComfyUI is launched in the background![/green]" )
429+ rich .print ("\n [green]✓ ComfyUI is launched in the background![/green]" )
422430 results = run_workflow (
423431 server .host ,
424432 server .port ,
@@ -428,17 +436,17 @@ def run(ctx, cpack: str, output_dir: str, help: bool, verbose: int):
428436 workspace = server .workspace ,
429437 ** validated_data .model_dump (),
430438 )
431- console .print ("\n [green]✓ Workflow is executed successfully![/green]" )
439+ rich .print ("\n [green]✓ Workflow is executed successfully![/green]" )
432440 if results :
433- console .print ("\n [green]✓ Retrieved outputs:[/green]" )
441+ rich .print ("\n [green]✓ Retrieved outputs:[/green]" )
434442 if isinstance (results , dict ):
435443 for field , value in results .items ():
436- console .print (f"{ field } : { value } " )
444+ rich .print (f"{ field } : { value } " )
437445 elif isinstance (results , list ):
438446 for i , value in enumerate (results ):
439- console .print (f"{ i } : { value } " )
447+ rich .print (f"{ i } : { value } " )
440448 else :
441- console .print (results )
449+ rich .print (results )
442450
443451
444452@main .command (name = "build-bento" )
0 commit comments