implemented api and progress updates via websocket

This commit is contained in:
donny committed 2026-01-03 16:49:42 -07:00
1 parent 5441b0d8ff
commit 7c8768ac1f
8 files changed
+325 -50

No files matched your search

+36 -9
View File
@@ -11,20 +11,31 @@ def load_workflow_module(workflow_name: str):
"""Dynamically load/reload a workflow module from the workflows folder."""
workflow_path = os.path.join(os.path.dirname(__file__), "workflows", f"{workflow_name}.py")
if not os.path.exists(workflow_path):
raise FileNotFoundError(f"Workflow file not found: {workflow_path}")
raise FileNotFoundError(f"Workflow script not found: {workflow_path}")
spec = importlib.util.spec_from_file_location(f"workflows.{workflow_name}", workflow_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
# Workflow registry - map workflow names to their file names
# Workflow registry - map workflow names to their config (file + metadata)
# The modules will be reloaded on each execution for hot reloading
WORKFLOW_FILES: Dict[str, str] = {
"test_workflow": "test",
WORKFLOW_FILES: Dict[str, dict] = {
"test_workflow": {
"script": "test",
"name": "Test Workflow",
"description": "Simple test workflow for image generation",
"model_types": ["SDXL", "Pony", "Illustrious"],
"category": "generation"
},
# Add more workflows here as you create them
# "image_generation": "example_image_gen",
# "upscale": "upscale_workflow",
# "image_generation": {
# "file": "example_image_gen",
# "name": "Image Generation",
# "description": "Advanced image generation with controlnets",
# "model_types": ["checkpoint", "lora", "controlnet"],
# "category": "generation"
# },
}
def get_workflow(name: str) -> Callable:
@@ -36,9 +47,25 @@ def get_workflow(name: str) -> Callable:
raise ValueError(f"Workflow '{name}' not found. Available: {list(WORKFLOW_FILES.keys())}")
# Reload the module from disk each time
module = load_workflow_module(WORKFLOW_FILES[name])
workflow_config = WORKFLOW_FILES[name]
module = load_workflow_module(workflow_config["script"])
return module.run_workflow
def get_workflow_metadata(name: str) -> dict:
"""Get metadata for a specific workflow."""
if name not in WORKFLOW_FILES:
raise ValueError(f"Workflow '{name}' not found. Available: {list(WORKFLOW_FILES.keys())}")
config = WORKFLOW_FILES[name].copy()
config.pop("script") # Don't expose internal file path
return config
def list_workflows() -> list:
"""Get list of available workflow names."""
return list(WORKFLOW_FILES.keys())
"""Get list of available workflow names with their metadata."""
return [
{
"id": name,
**get_workflow_metadata(name)
}
for name in WORKFLOW_FILES.keys()
]