Commit ·
d7ff660
1
Parent(s): cf4e044
Revert "Revert "Skip re-cloning ComfyUI on restart to speed up startup""
Browse filesThis reverts commit cf4e0444badb845fdb76b029e1bab9f7f39e571b.
- comfy_integration/setup.py +27 -21
comfy_integration/setup.py
CHANGED
|
@@ -16,28 +16,34 @@ def move_and_overwrite(src, dst):
|
|
| 16 |
|
| 17 |
def initialize_comfyui():
|
| 18 |
APP_DIR = sys.path[0]
|
|
|
|
|
|
|
|
|
|
| 19 |
COMFYUI_TEMP_DIR = "ComfyUI_temp"
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
os.system(f"git clone https://github.com/comfy-Org/ComfyUI {COMFYUI_TEMP_DIR}")
|
| 24 |
-
print("✅ ComfyUI repository cloned.")
|
| 25 |
else:
|
| 26 |
-
print("
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
print("--- Cloning third-party extensions for ComfyUI ---")
|
| 43 |
|
|
@@ -99,7 +105,6 @@ def initialize_comfyui():
|
|
| 99 |
torch.cuda.current_device = lambda: 0
|
| 100 |
torch.cuda.get_device_name = lambda device: "cpu"
|
| 101 |
|
| 102 |
-
|
| 103 |
# Apply patch to the external ComfyUI model_management before import.
|
| 104 |
external_model_mgmt_path = os.path.join(APP_DIR, "comfy", "model_management.py")
|
| 105 |
if os.path.exists(external_model_mgmt_path):
|
|
@@ -177,7 +182,6 @@ def initialize_comfyui():
|
|
| 177 |
return False
|
| 178 |
model_mgmt.should_use_bf16 = _safe_should_use_bf16
|
| 179 |
|
| 180 |
-
|
| 181 |
print("--- Environment Ready ---")
|
| 182 |
|
| 183 |
print("✅ ComfyUI initialized with default attention mechanism.")
|
|
@@ -189,3 +193,5 @@ def initialize_comfyui():
|
|
| 189 |
os.makedirs(os.path.join(APP_DIR, OUTPUT_DIR), exist_ok=True)
|
| 190 |
|
| 191 |
print("✅ All required model directories are present.")
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def initialize_comfyui():
|
| 18 |
APP_DIR = sys.path[0]
|
| 19 |
+
# Check if ComfyUI already exists in the app directory to avoid re-cloning on every restart.
|
| 20 |
+
# The presence of the 'comfy' package (imported later) indicates a previous successful setup.
|
| 21 |
+
COMFYUI_PRESENT = os.path.isdir(os.path.join(APP_DIR, 'comfy'))
|
| 22 |
COMFYUI_TEMP_DIR = "ComfyUI_temp"
|
| 23 |
|
| 24 |
+
if COMFYUI_PRESENT:
|
| 25 |
+
print("✅ ComfyUI already initialized – skipping clone and merge.")
|
|
|
|
|
|
|
| 26 |
else:
|
| 27 |
+
print("--- Cloning ComfyUI Repository ---")
|
| 28 |
+
if not os.path.exists(COMFYUI_TEMP_DIR):
|
| 29 |
+
os.system(f"git clone https://github.com/comfy-Org/ComfyUI {COMFYUI_TEMP_DIR}")
|
| 30 |
+
print("✅ ComfyUI repository cloned.")
|
| 31 |
+
else:
|
| 32 |
+
print("✅ ComfyUI repository already exists.")
|
| 33 |
+
|
| 34 |
+
print(f"--- Merging ComfyUI from '{COMFYUI_TEMP_DIR}' to '{APP_DIR}' ---")
|
| 35 |
+
for item in os.listdir(COMFYUI_TEMP_DIR):
|
| 36 |
+
src_path = os.path.join(COMFYUI_TEMP_DIR, item)
|
| 37 |
+
dst_path = os.path.join(APP_DIR, item)
|
| 38 |
+
if item == '.git':
|
| 39 |
+
continue
|
| 40 |
+
move_and_overwrite(src_path, dst_path)
|
| 41 |
+
|
| 42 |
+
try:
|
| 43 |
+
shutil.rmtree(COMFYUI_TEMP_DIR)
|
| 44 |
+
print("✅ ComfyUI merged and temporary directory removed.")
|
| 45 |
+
except OSError as e:
|
| 46 |
+
print(f"⚠️ Could not remove temporary directory '{COMFYUI_TEMP_DIR}': {e}")
|
| 47 |
|
| 48 |
print("--- Cloning third-party extensions for ComfyUI ---")
|
| 49 |
|
|
|
|
| 105 |
torch.cuda.current_device = lambda: 0
|
| 106 |
torch.cuda.get_device_name = lambda device: "cpu"
|
| 107 |
|
|
|
|
| 108 |
# Apply patch to the external ComfyUI model_management before import.
|
| 109 |
external_model_mgmt_path = os.path.join(APP_DIR, "comfy", "model_management.py")
|
| 110 |
if os.path.exists(external_model_mgmt_path):
|
|
|
|
| 182 |
return False
|
| 183 |
model_mgmt.should_use_bf16 = _safe_should_use_bf16
|
| 184 |
|
|
|
|
| 185 |
print("--- Environment Ready ---")
|
| 186 |
|
| 187 |
print("✅ ComfyUI initialized with default attention mechanism.")
|
|
|
|
| 193 |
os.makedirs(os.path.join(APP_DIR, OUTPUT_DIR), exist_ok=True)
|
| 194 |
|
| 195 |
print("✅ All required model directories are present.")
|
| 196 |
+
|
| 197 |
+
print("✅ All required model directories are present.")
|