mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 07:05:43 -03:00
Remove custom websocket event type and related progress sending logic from LorasEndpoint
This commit is contained in:
@@ -6,9 +6,6 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
|
|
||||||
WEB_DIRECTORY = "./js"
|
WEB_DIRECTORY = "./js"
|
||||||
|
|
||||||
# Add custom websocket event type
|
|
||||||
EXTENSION_WEB_SOCKET_MESSAGE_TYPES = ["lora-scan-progress"]
|
|
||||||
|
|
||||||
# Add this init function to properly register routes
|
# Add this init function to properly register routes
|
||||||
def init():
|
def init():
|
||||||
LorasEndpoint.add_routes()
|
LorasEndpoint.add_routes()
|
||||||
|
|||||||
17
nodes.py
17
nodes.py
@@ -49,28 +49,14 @@ class LorasEndpoint:
|
|||||||
web.post('/api/replace_preview', instance.replace_preview),
|
web.post('/api/replace_preview', instance.replace_preview),
|
||||||
])
|
])
|
||||||
|
|
||||||
def send_progress(self, current, total, status="Scanning"):
|
|
||||||
"""Send progress through websocket"""
|
|
||||||
try:
|
|
||||||
if hasattr(self.server, 'send_sync'):
|
|
||||||
self.server.send_sync("lora-scan-progress", {
|
|
||||||
"value": current,
|
|
||||||
"max": total,
|
|
||||||
"status": status
|
|
||||||
})
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error sending progress: {str(e)}")
|
|
||||||
|
|
||||||
async def scan_loras(self):
|
async def scan_loras(self):
|
||||||
loras = []
|
loras = []
|
||||||
for loras_root in self.loras_roots:
|
for loras_root in self.loras_roots:
|
||||||
for root, _, files in os.walk(loras_root):
|
for root, _, files in os.walk(loras_root):
|
||||||
safetensors_files = [f for f in files if f.endswith('.safetensors')]
|
safetensors_files = [f for f in files if f.endswith('.safetensors')]
|
||||||
total_files = len(safetensors_files)
|
|
||||||
|
|
||||||
for idx, filename in enumerate(safetensors_files, 1):
|
|
||||||
self.send_progress(idx, total_files, f"Scanning: {filename}")
|
|
||||||
|
|
||||||
|
for filename in safetensors_files:
|
||||||
file_path = os.path.join(root, filename).replace(os.sep, "/")
|
file_path = os.path.join(root, filename).replace(os.sep, "/")
|
||||||
|
|
||||||
# Try to load existing metadata first
|
# Try to load existing metadata first
|
||||||
@@ -93,7 +79,6 @@ class LorasEndpoint:
|
|||||||
|
|
||||||
loras.append(lora_data)
|
loras.append(lora_data)
|
||||||
|
|
||||||
self.send_progress(total_files, total_files, "Scan completed")
|
|
||||||
return loras
|
return loras
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user