Added the workflow manager to the RS Settings Manager extension
This commit is contained in:
@@ -6,6 +6,7 @@ __pycache__/
|
||||
preset_colors/
|
||||
preset_models/
|
||||
presets/
|
||||
presets_workflow
|
||||
prompts/
|
||||
rayko_lora_data/
|
||||
styles/
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ IGNORED_MODULES: Set[str] = {'__init__.py'}
|
||||
REQUIRED_MODULES: Set[str] = set()
|
||||
|
||||
PACKAGE_DISPLAY_NAME = "ComfyUI_RaykoStudio"
|
||||
__version__ = "0.51.4"
|
||||
__version__ = "0.52.0"
|
||||
|
||||
def load_modules():
|
||||
print(f"🦊 {PACKAGE_DISPLAY_NAME}: Version: {__version__}")
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ComfyUI_RaykoStudio",
|
||||
"version": "0.51.4",
|
||||
"version": "0.52.0",
|
||||
"description": "Set of custom nodes for ComfyUI providing additional image processing capabilities",
|
||||
"author": "Raykosan",
|
||||
"license": "Apache License 2.0",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "ComfyUI_RaykoStudio"
|
||||
description = "Set of custom nodes for ComfyUI providing additional image processing capabilities"
|
||||
version = "0.51.4"
|
||||
version = "0.52.0"
|
||||
license = { file = "LICENSE" }
|
||||
dependencies = ["torch", "opencv-python", "numpy", "Pillow>=10.0.0", "freetype-py>=2.5.1", "pycairo>=1.29.0", "scipy>=1.10.0"]
|
||||
|
||||
|
||||
+105
-11
@@ -15,6 +15,7 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import shutil
|
||||
import datetime
|
||||
import logging
|
||||
@@ -28,20 +29,27 @@ CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
COMFYUI_ROOT = os.path.dirname(os.path.dirname(CURRENT_DIR))
|
||||
SETTINGS_FILE = os.path.join(COMFYUI_ROOT, "user", "default", "comfy.settings.json")
|
||||
BACKUP_DIR = os.path.join(os.path.expanduser("~"), "Documents", "ComfyUI_Settings_Backups")
|
||||
PRESETS_DIR = os.path.join(CURRENT_DIR, "presets_workflow")
|
||||
|
||||
os.makedirs(BACKUP_DIR, exist_ok=True)
|
||||
os.makedirs(PRESETS_DIR, exist_ok=True)
|
||||
logger.info("🦊 Settings Manager initialized")
|
||||
logger.info(f"🦊 Presets folder: {PRESETS_DIR}")
|
||||
|
||||
|
||||
# -------------------- Settings Backups --------------------
|
||||
|
||||
@PromptServer.instance.routes.get("/rayko_settings_manager/ping")
|
||||
async def ping(request):
|
||||
return web.json_response({"status": "ok"})
|
||||
|
||||
|
||||
@PromptServer.instance.routes.post("/rayko_settings_manager/save")
|
||||
async def save_settings(request):
|
||||
try:
|
||||
if not os.path.exists(SETTINGS_FILE):
|
||||
return web.json_response({"error": "Settings file not found"}, status=404)
|
||||
|
||||
|
||||
try:
|
||||
data = await request.json()
|
||||
custom_name = data.get('backup_name', '').strip()
|
||||
@@ -62,60 +70,64 @@ async def save_settings(request):
|
||||
target_folder = os.path.join(BACKUP_DIR, folder_name)
|
||||
os.makedirs(target_folder, exist_ok=True)
|
||||
shutil.copy2(SETTINGS_FILE, target_folder)
|
||||
|
||||
|
||||
return web.json_response({"success": True, "folder": folder_name})
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
@PromptServer.instance.routes.get("/rayko_settings_manager/list")
|
||||
async def list_settings(request):
|
||||
try:
|
||||
if not os.path.exists(BACKUP_DIR):
|
||||
return web.json_response({"success": True, "backups": []})
|
||||
|
||||
|
||||
backups = [d for d in os.listdir(BACKUP_DIR) if os.path.isdir(os.path.join(BACKUP_DIR, d))]
|
||||
backups.sort(reverse=True)
|
||||
return web.json_response({"success": True, "backups": backups})
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
@PromptServer.instance.routes.post("/rayko_settings_manager/restore")
|
||||
async def restore_settings(request):
|
||||
try:
|
||||
data = await request.json()
|
||||
backup_name = data.get("backup_name")
|
||||
|
||||
|
||||
if not backup_name:
|
||||
return web.json_response({"error": "Backup name not specified"}, status=400)
|
||||
|
||||
|
||||
backup_file = os.path.join(BACKUP_DIR, backup_name, "comfy.settings.json")
|
||||
|
||||
|
||||
if not os.path.exists(backup_file):
|
||||
return web.json_response({"error": "Backup file not found"}, status=404)
|
||||
|
||||
|
||||
shutil.copy2(backup_file, SETTINGS_FILE)
|
||||
return web.json_response({"success": True})
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
@PromptServer.instance.routes.delete("/rayko_settings_manager/delete/{backup_name}")
|
||||
async def delete_backup(request):
|
||||
try:
|
||||
backup_name = request.match_info.get('backup_name')
|
||||
|
||||
|
||||
if not backup_name:
|
||||
return web.json_response({"error": "Backup name not specified"}, status=400)
|
||||
|
||||
|
||||
backup_path = os.path.join(BACKUP_DIR, backup_name)
|
||||
|
||||
|
||||
if not os.path.exists(backup_path):
|
||||
return web.json_response({"error": "Backup not found"}, status=404)
|
||||
|
||||
|
||||
shutil.rmtree(backup_path)
|
||||
return web.json_response({"success": True})
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
@PromptServer.instance.routes.post("/rayko_settings_manager/restart")
|
||||
async def restart_server(request):
|
||||
try:
|
||||
@@ -124,5 +136,87 @@ async def restart_server(request):
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
# -------------------- Workflow Presets --------------------
|
||||
|
||||
def _sanitize_name(name: str) -> str:
|
||||
return re.sub(r'[<>:"/\\|?*]', '_', (name or "").strip()).rstrip('. ')
|
||||
|
||||
|
||||
@PromptServer.instance.routes.get("/rayko_settings_manager/presets/list")
|
||||
async def list_presets(request):
|
||||
try:
|
||||
presets = []
|
||||
if os.path.exists(PRESETS_DIR):
|
||||
for f in sorted(os.listdir(PRESETS_DIR)):
|
||||
if not f.endswith(".json"):
|
||||
continue
|
||||
try:
|
||||
with open(os.path.join(PRESETS_DIR, f), "r", encoding="utf-8") as fp:
|
||||
data = json.load(fp)
|
||||
presets.append({
|
||||
"name": f[:-5],
|
||||
"count": len(data.get("workflows", [])),
|
||||
})
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to read preset {f}: {e}")
|
||||
return web.json_response({"success": True, "presets": presets})
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
@PromptServer.instance.routes.get("/rayko_settings_manager/presets/get/{name}")
|
||||
async def get_preset(request):
|
||||
try:
|
||||
name = _sanitize_name(request.match_info.get("name") or "")
|
||||
if not name:
|
||||
return web.json_response({"error": "Name required"}, status=400)
|
||||
path = os.path.join(PRESETS_DIR, f"{name}.json")
|
||||
if not os.path.exists(path):
|
||||
return web.json_response({"error": "Not found"}, status=404)
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
return web.json_response(json.load(f))
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
@PromptServer.instance.routes.post("/rayko_settings_manager/presets/save")
|
||||
async def save_preset(request):
|
||||
try:
|
||||
data = await request.json()
|
||||
name = _sanitize_name(data.get("name", ""))
|
||||
workflows = data.get("workflows", [])
|
||||
if not name:
|
||||
return web.json_response({"error": "Name required"}, status=400)
|
||||
if not workflows:
|
||||
return web.json_response({"error": "No workflows to save"}, status=400)
|
||||
|
||||
payload = {
|
||||
"created": datetime.datetime.now().isoformat(timespec="seconds"),
|
||||
"workflows": workflows,
|
||||
}
|
||||
path = os.path.join(PRESETS_DIR, f"{name}.json")
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
json.dump(payload, f, ensure_ascii=False, indent=2)
|
||||
return web.json_response({"success": True, "name": name, "count": len(workflows)})
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
@PromptServer.instance.routes.delete("/rayko_settings_manager/presets/delete/{name}")
|
||||
async def delete_preset(request):
|
||||
try:
|
||||
name = _sanitize_name(request.match_info.get("name") or "")
|
||||
if not name:
|
||||
return web.json_response({"error": "Name required"}, status=400)
|
||||
path = os.path.join(PRESETS_DIR, f"{name}.json")
|
||||
if not os.path.exists(path):
|
||||
return web.json_response({"error": "Not found"}, status=404)
|
||||
os.remove(path)
|
||||
return web.json_response({"success": True})
|
||||
except Exception as e:
|
||||
return web.json_response({"error": str(e)}, status=500)
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {}
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {}
|
||||
+988
-344
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user