Commit ·
d1dc2f7
1
Parent(s): d7ff660
Revert "Revert "Revert "Skip re-cloning ComfyUI on restart to speed up startup"""
Browse filesThis reverts commit d7ff6601bb01717f0a0762f84e8bef99b46004c3.
- comfy_integration/setup.py +21 -27
comfy_integration/setup.py
CHANGED
|
@@ -16,34 +16,28 @@ def move_and_overwrite(src, dst):
|
|
| 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 |
-
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
else:
|
| 27 |
-
print("
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 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,6 +99,7 @@ def initialize_comfyui():
|
|
| 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,6 +177,7 @@ def initialize_comfyui():
|
|
| 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,5 +189,3 @@ def initialize_comfyui():
|
|
| 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.")
|
|
|
|
| 16 |
|
| 17 |
def initialize_comfyui():
|
| 18 |
APP_DIR = sys.path[0]
|
|
|
|
|
|
|
|
|
|
| 19 |
COMFYUI_TEMP_DIR = "ComfyUI_temp"
|
| 20 |
|
| 21 |
+
print("--- Cloning ComfyUI Repository ---")
|
| 22 |
+
if not os.path.exists(COMFYUI_TEMP_DIR):
|
| 23 |
+
os.system(f"git clone https://github.com/comfy-Org/ComfyUI {COMFYUI_TEMP_DIR}")
|
| 24 |
+
print("✅ ComfyUI repository cloned.")
|
| 25 |
else:
|
| 26 |
+
print("✅ ComfyUI repository already exists.")
|
| 27 |
+
|
| 28 |
+
print(f"--- Merging ComfyUI from '{COMFYUI_TEMP_DIR}' to '{APP_DIR}' ---")
|
| 29 |
+
for item in os.listdir(COMFYUI_TEMP_DIR):
|
| 30 |
+
src_path = os.path.join(COMFYUI_TEMP_DIR, item)
|
| 31 |
+
dst_path = os.path.join(APP_DIR, item)
|
| 32 |
+
if item == '.git':
|
| 33 |
+
continue
|
| 34 |
+
move_and_overwrite(src_path, dst_path)
|
| 35 |
+
|
| 36 |
+
try:
|
| 37 |
+
shutil.rmtree(COMFYUI_TEMP_DIR)
|
| 38 |
+
print("✅ ComfyUI merged and temporary directory removed.")
|
| 39 |
+
except OSError as e:
|
| 40 |
+
print(f"⚠️ Could not remove temporary directory '{COMFYUI_TEMP_DIR}': {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
print("--- Cloning third-party extensions for ComfyUI ---")
|
| 43 |
|
|
|
|
| 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 |
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 |
os.makedirs(os.path.join(APP_DIR, OUTPUT_DIR), exist_ok=True)
|
| 190 |
|
| 191 |
print("✅ All required model directories are present.")
|
|
|
|
|
|