Full source for the-third-rev: Discord bot (discord.py), FastAPI web UI (React/TS/Vite/Tailwind), ComfyUI integration, generation history DB, preset manager, workflow inspector, and all supporting modules. Excluded from tracking: .env, invite_tokens.json, *.db (SQLite), current-workflow-changes.json, user_settings/, presets/, logs/, web-static/ (build output), frontend/node_modules/. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
57 lines
1.5 KiB
Python
57 lines
1.5 KiB
Python
"""
|
|
workflow_manager.py
|
|
===================
|
|
|
|
Workflow template storage for the Discord ComfyUI bot.
|
|
|
|
This module provides a WorkflowManager class responsible solely for holding
|
|
the loaded workflow template. Node inspection and injection are handled by
|
|
:class:`~workflow_inspector.WorkflowInspector`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from typing import Dict, Optional, Any
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class WorkflowManager:
|
|
"""
|
|
Stores and provides access to the current workflow template.
|
|
|
|
Parameters
|
|
----------
|
|
workflow_template : Optional[Dict[str, Any]]
|
|
An initial workflow dict. If None, no template is loaded and one
|
|
must be set via :meth:`set_workflow_template`.
|
|
"""
|
|
|
|
def __init__(self, workflow_template: Optional[Dict[str, Any]] = None) -> None:
|
|
self._workflow_template = workflow_template
|
|
|
|
def set_workflow_template(self, workflow: Dict[str, Any]) -> None:
|
|
"""
|
|
Set or replace the workflow template.
|
|
|
|
Parameters
|
|
----------
|
|
workflow : Dict[str, Any]
|
|
Workflow dictionary in ComfyUI API format.
|
|
"""
|
|
self._workflow_template = workflow
|
|
logger.info("Workflow template updated (%d nodes)", len(workflow))
|
|
|
|
def get_workflow_template(self) -> Optional[Dict[str, Any]]:
|
|
"""
|
|
Return the current workflow template.
|
|
|
|
Returns
|
|
-------
|
|
Optional[Dict[str, Any]]
|
|
The loaded template, or None if none has been set.
|
|
"""
|
|
return self._workflow_template
|