From 32e003965af5013b4828267439eb4fce9c835822 Mon Sep 17 00:00:00 2001 From: bymyself Date: Tue, 17 Jun 2025 10:36:52 -0700 Subject: [PATCH] fix `files` description in api --- comfyui_manager/data_models/__init__.py | 12 +- .../data_models/generated_models.py | 117 +++++++++++------- 2 files changed, 77 insertions(+), 52 deletions(-) diff --git a/comfyui_manager/data_models/__init__.py b/comfyui_manager/data_models/__init__.py index fe48ecbe..ad27d7c5 100644 --- a/comfyui_manager/data_models/__init__.py +++ b/comfyui_manager/data_models/__init__.py @@ -31,8 +31,8 @@ from .generated_models import ( ComfyUIVersionInfo, # Other models - Kind, - StatusStr, + OperationType, + OperationResult, ManagerPackInfo, ManagerPackInstalled, SelectedVersion, @@ -59,8 +59,6 @@ from .generated_models import ( HistoryResponse, HistoryListResponse, InstallType, - OperationType, - Result, ) __all__ = [ @@ -86,8 +84,8 @@ __all__ = [ "ComfyUIVersionInfo", # Other models - "Kind", - "StatusStr", + "OperationType", + "OperationResult", "ManagerPackInfo", "ManagerPackInstalled", "SelectedVersion", @@ -114,6 +112,4 @@ __all__ = [ "HistoryResponse", "HistoryListResponse", "InstallType", - "OperationType", - "Result", ] \ No newline at end of file diff --git a/comfyui_manager/data_models/generated_models.py b/comfyui_manager/data_models/generated_models.py index 142156fd..bd582290 100644 --- a/comfyui_manager/data_models/generated_models.py +++ b/comfyui_manager/data_models/generated_models.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: openapi.yaml -# timestamp: 2025-06-14T01:44:21+00:00 +# timestamp: 2025-06-17T17:32:47+00:00 from __future__ import annotations @@ -8,10 +8,14 @@ from datetime import datetime from enum import Enum from typing import Any, Dict, List, Optional, Union -from pydantic import BaseModel, Field, RootModel +from pydantic import BaseModel, Field -class Kind(str, Enum): +class OperationType(Enum): + """ + Type of operation or task being performed + """ + install = 'install' uninstall = 'uninstall' update = 'update' @@ -23,19 +27,29 @@ class Kind(str, Enum): install_model = 'install-model' -class StatusStr(str, Enum): +class OperationResult(Enum): + """ + Result status of an operation (failed/error and skipped/skip are aliases) + """ + success = 'success' + failed = 'failed' + skipped = 'skipped' error = 'error' skip = 'skip' class TaskExecutionStatus(BaseModel): - status_str: StatusStr = Field(..., description='Overall task execution status') + status_str: OperationResult completed: bool = Field(..., description='Whether the task completed') messages: List[str] = Field(..., description='Additional status messages') -class ManagerMessageName(str, Enum): +class ManagerMessageName(Enum): + """ + WebSocket message type constants for manager events + """ + cm_task_completed = 'cm-task-completed' cm_task_started = 'cm-task-started' cm_queue_status = 'cm-queue-status' @@ -65,12 +79,20 @@ class ManagerPackInstalled(BaseModel): enabled: bool = Field(..., description='Whether the pack is enabled') -class SelectedVersion(str, Enum): +class SelectedVersion(Enum): + """ + Version selection for pack installation + """ + latest = 'latest' nightly = 'nightly' -class ManagerChannel(str, Enum): +class ManagerChannel(Enum): + """ + Channel for pack sources + """ + default = 'default' recent = 'recent' legacy = 'legacy' @@ -79,13 +101,21 @@ class ManagerChannel(str, Enum): tutorial = 'tutorial' -class ManagerDatabaseSource(str, Enum): +class ManagerDatabaseSource(Enum): + """ + Source for pack information + """ + remote = 'remote' local = 'local' cache = 'cache' -class ManagerPackState(str, Enum): +class ManagerPackState(Enum): + """ + Current state of a pack + """ + installed = 'installed' disabled = 'disabled' not_installed = 'not_installed' @@ -93,13 +123,21 @@ class ManagerPackState(str, Enum): needs_update = 'needs_update' -class ManagerPackInstallType(str, Enum): +class ManagerPackInstallType(Enum): + """ + Type of installation used for the pack + """ + git_clone = 'git-clone' copy = 'copy' cnr = 'cnr' class UpdateState(Enum): + """ + Update availability status + """ + false = 'false' true = 'true' @@ -108,7 +146,10 @@ class ManagerPack(ManagerPackInfo): author: Optional[str] = Field( None, description="Pack author name or 'Unclaimed' if added via GitHub crawl" ) - files: Optional[List[str]] = Field(None, description='Files included in the pack') + files: Optional[List[str]] = Field( + None, + description='Repository URLs for installation (typically contains one GitHub URL)', + ) reference: Optional[str] = Field( None, description='The type of installation reference' ) @@ -210,10 +251,8 @@ class ManagerMappings1(BaseModel): title_aux: Optional[str] = Field(None, description='The display name of the pack') -class ManagerMappings( - RootModel[Optional[Dict[str, List[Union[List[str], ManagerMappings1]]]]] -): - root: Optional[Dict[str, List[Union[List[str], ManagerMappings1]]]] = Field( +class ManagerMappings(BaseModel): + __root__: Optional[Dict[str, List[Union[List[str], ManagerMappings1]]]] = Field( None, description='Tuple of [node_names, metadata]' ) @@ -228,7 +267,11 @@ class ModelMetadata(BaseModel): ui_id: Optional[str] = Field(None, description='ID for UI reference') -class InstallType(str, Enum): +class InstallType(Enum): + """ + Installation method + """ + git = 'git' copy = 'copy' pip = 'pip' @@ -251,16 +294,20 @@ class NodePackageMetadata(BaseModel): mode: Optional[str] = Field(None, description='Source mode') -class SnapshotItem(RootModel[str]): - root: str = Field(..., description='Name of the snapshot') +class SnapshotItem(BaseModel): + __root__: str = Field(..., description='Name of the snapshot') class Error(BaseModel): error: str = Field(..., description='Error message') -class InstalledPacksResponse(RootModel[Optional[Dict[str, ManagerPackInstalled]]]): - root: Optional[Dict[str, ManagerPackInstalled]] = None +class InstalledPacksResponse(BaseModel): + """ + Map of pack names to their installation info + """ + + __root__: Optional[Dict[str, ManagerPackInstalled]] = None class HistoryListResponse(BaseModel): @@ -307,32 +354,16 @@ class ComfyUIVersionInfo(BaseModel): ) -class OperationType(str, Enum): - install = 'install' - update = 'update' - uninstall = 'uninstall' - fix = 'fix' - disable = 'disable' - enable = 'enable' - install_model = 'install-model' - - -class Result(str, Enum): - success = 'success' - failed = 'failed' - skipped = 'skipped' - - class BatchOperation(BaseModel): operation_id: str = Field(..., description='Unique operation identifier') - operation_type: OperationType = Field(..., description='Type of operation') + operation_type: OperationType target: str = Field( ..., description='Target of the operation (node name, model name, etc.)' ) target_version: Optional[str] = Field( None, description='Target version for the operation' ) - result: Result = Field(..., description='Operation result') + result: OperationResult error_message: Optional[str] = Field( None, description='Error message if operation failed' ) @@ -400,7 +431,7 @@ class BatchExecutionRecord(BaseModel): class QueueTaskItem(BaseModel): ui_id: str = Field(..., description='Unique identifier for the task') client_id: str = Field(..., description='Client identifier that initiated the task') - kind: Kind = Field(..., description='Type of task being performed') + kind: OperationType params: Union[ InstallPackParams, UpdatePackParams, @@ -462,10 +493,8 @@ class MessageTaskFailed(BaseModel): state: TaskStateMessage -class MessageUpdate( - RootModel[Union[MessageTaskDone, MessageTaskStarted, MessageTaskFailed]] -): - root: Union[MessageTaskDone, MessageTaskStarted, MessageTaskFailed] = Field( +class MessageUpdate(BaseModel): + __root__: Union[MessageTaskDone, MessageTaskStarted, MessageTaskFailed] = Field( ..., description='Union type for all possible WebSocket message updates' )