mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-07-27 08:16:44 +00:00
Refactored io.py, ui.py, and resources.py to expose themselves on v3/__init__.py on _IO, _UI, and _RESOURCES classes such that the v3 schema can be iterated upon on versioned Core API soon
This commit is contained in:
parent
7d710727a9
commit
3a8286b034
@ -0,0 +1,9 @@
|
|||||||
|
from comfy_api.v3._io import _IO
|
||||||
|
from comfy_api.v3._ui import _UI
|
||||||
|
from comfy_api.v3._resources import _RESOURCES
|
||||||
|
|
||||||
|
io = _IO
|
||||||
|
ui = _UI
|
||||||
|
resources = _RESOURCES
|
||||||
|
|
||||||
|
__all__ = ["io", "ui", "resources"]
|
@ -24,7 +24,7 @@ from comfy.sd import StyleModel as StyleModel_
|
|||||||
from comfy_api.input import VideoInput
|
from comfy_api.input import VideoInput
|
||||||
from comfy_api.internal import (_ComfyNodeInternal, classproperty, copy_class, first_real_override, is_class,
|
from comfy_api.internal import (_ComfyNodeInternal, classproperty, copy_class, first_real_override, is_class,
|
||||||
prune_dict, shallow_clone_class)
|
prune_dict, shallow_clone_class)
|
||||||
from comfy_api.v3.resources import Resources, ResourcesLocal
|
from comfy_api.v3._resources import Resources, ResourcesLocal
|
||||||
from comfy_execution.graph import ExecutionBlocker
|
from comfy_execution.graph import ExecutionBlocker
|
||||||
|
|
||||||
# from comfy_extras.nodes_images import SVG as SVG_ # NOTE: needs to be moved before can be imported due to circular reference
|
# from comfy_extras.nodes_images import SVG as SVG_ # NOTE: needs to be moved before can be imported due to circular reference
|
||||||
@ -1502,5 +1502,76 @@ class _UIOutput(ABC):
|
|||||||
def as_dict(self) -> dict:
|
def as_dict(self) -> dict:
|
||||||
...
|
...
|
||||||
|
|
||||||
class IO:
|
|
||||||
|
class _IO:
|
||||||
FolderType = FolderType
|
FolderType = FolderType
|
||||||
|
UploadType = UploadType
|
||||||
|
RemoteOptions = RemoteOptions
|
||||||
|
NumberDisplay = NumberDisplay
|
||||||
|
comfytype = staticmethod(comfytype)
|
||||||
|
Custom = staticmethod(Custom)
|
||||||
|
InputV3 = InputV3
|
||||||
|
WidgetInputV3 = WidgetInputV3
|
||||||
|
OutputV3 = OutputV3
|
||||||
|
ComfyTypeI = ComfyTypeI
|
||||||
|
ComfyTypeIO = ComfyTypeIO
|
||||||
|
Boolean = Boolean
|
||||||
|
Int = Int
|
||||||
|
Float = Float
|
||||||
|
String = String
|
||||||
|
Combo = Combo
|
||||||
|
MultiCombo = MultiCombo
|
||||||
|
Image = Image
|
||||||
|
WanCameraEmbedding = WanCameraEmbedding
|
||||||
|
Webcam = Webcam
|
||||||
|
Mask = Mask
|
||||||
|
Latent = Latent
|
||||||
|
Conditioning = Conditioning
|
||||||
|
Sampler = Sampler
|
||||||
|
Sigmas = Sigmas
|
||||||
|
Noise = Noise
|
||||||
|
Guider = Guider
|
||||||
|
Clip = Clip
|
||||||
|
ControlNet = ControlNet
|
||||||
|
Vae = Vae
|
||||||
|
Model = Model
|
||||||
|
ClipVision = ClipVision
|
||||||
|
ClipVisionOutput = ClipVisionOutput
|
||||||
|
StyleModel = StyleModel
|
||||||
|
Gligen = Gligen
|
||||||
|
UpscaleModel = UpscaleModel
|
||||||
|
Audio = Audio
|
||||||
|
Video = Video
|
||||||
|
SVG = SVG
|
||||||
|
LoraModel = LoraModel
|
||||||
|
LossMap = LossMap
|
||||||
|
Voxel = Voxel
|
||||||
|
Mesh = Mesh
|
||||||
|
Hooks = Hooks
|
||||||
|
HookKeyframes = HookKeyframes
|
||||||
|
TimestepsRange = TimestepsRange
|
||||||
|
LatentOperation = LatentOperation
|
||||||
|
FlowControl = FlowControl
|
||||||
|
Accumulation = Accumulation
|
||||||
|
Load3DCamera = Load3DCamera
|
||||||
|
Photomaker = Photomaker
|
||||||
|
Point = Point
|
||||||
|
FaceAnalysis = FaceAnalysis
|
||||||
|
BBOX = BBOX
|
||||||
|
SEGS = SEGS
|
||||||
|
AnyType = AnyType
|
||||||
|
MultiType = MultiType
|
||||||
|
DynamicInput = DynamicInput
|
||||||
|
DynamicOutput = DynamicOutput
|
||||||
|
AutogrowDynamic = AutogrowDynamic
|
||||||
|
ComboDynamicInput = ComboDynamicInput
|
||||||
|
MatchType = MatchType
|
||||||
|
HiddenHolder = HiddenHolder
|
||||||
|
Hidden = Hidden
|
||||||
|
NodeInfoV1 = NodeInfoV1
|
||||||
|
NodeInfoV3 = NodeInfoV3
|
||||||
|
Schema = Schema
|
||||||
|
ComfyNode = ComfyNode
|
||||||
|
NodeOutput = NodeOutput
|
||||||
|
add_to_dict_v1 = staticmethod(add_to_dict_v1)
|
||||||
|
add_to_dict_v3 = staticmethod(add_to_dict_v3)
|
||||||
|
@ -63,3 +63,10 @@ class ResourcesLocal(Resources):
|
|||||||
if default is not ...:
|
if default is not ...:
|
||||||
return default
|
return default
|
||||||
raise Exception(f"Unsupported resource key type: {type(key)}")
|
raise Exception(f"Unsupported resource key type: {type(key)}")
|
||||||
|
|
||||||
|
|
||||||
|
class _RESOURCES:
|
||||||
|
ResourceKey = ResourceKey
|
||||||
|
TorchDictFolderFilename = TorchDictFolderFilename
|
||||||
|
Resources = Resources
|
||||||
|
ResourcesLocal = ResourcesLocal
|
||||||
|
@ -17,7 +17,7 @@ import folder_paths
|
|||||||
|
|
||||||
# used for image preview
|
# used for image preview
|
||||||
from comfy.cli_args import args
|
from comfy.cli_args import args
|
||||||
from comfy_api.v3.io import ComfyNode, FolderType, Image, _UIOutput
|
from comfy_api.v3._io import ComfyNode, FolderType, Image, _UIOutput
|
||||||
|
|
||||||
|
|
||||||
class SavedResult(dict):
|
class SavedResult(dict):
|
||||||
@ -488,3 +488,17 @@ class PreviewText(_UIOutput):
|
|||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
return {"text": (self.value,)}
|
return {"text": (self.value,)}
|
||||||
|
|
||||||
|
|
||||||
|
class _UI:
|
||||||
|
SavedResult = SavedResult
|
||||||
|
SavedImages = SavedImages
|
||||||
|
SavedAudios = SavedAudios
|
||||||
|
ImageSaveHelper = ImageSaveHelper
|
||||||
|
AudioSaveHelper = AudioSaveHelper
|
||||||
|
PreviewImage = PreviewImage
|
||||||
|
PreviewMask = PreviewMask
|
||||||
|
PreviewAudio = PreviewAudio
|
||||||
|
PreviewVideo = PreviewVideo
|
||||||
|
PreviewUI3D = PreviewUI3D
|
||||||
|
PreviewText = PreviewText
|
||||||
|
21
comfy_api/v3_01/__init__.py
Normal file
21
comfy_api/v3_01/__init__.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
from comfy_api.v3._io import _IO
|
||||||
|
from comfy_api.v3._ui import _UI
|
||||||
|
from comfy_api.v3._resources import _RESOURCES
|
||||||
|
import logging
|
||||||
|
|
||||||
|
class Int(_IO.Int):
|
||||||
|
class Input(_IO.Int.Input):
|
||||||
|
def as_dict(self):
|
||||||
|
logging.info("I am in V3_01 def of Int 😎")
|
||||||
|
return super().as_dict()
|
||||||
|
|
||||||
|
|
||||||
|
class IO_01(_IO):
|
||||||
|
Int = Int
|
||||||
|
|
||||||
|
|
||||||
|
io = IO_01
|
||||||
|
ui = _UI
|
||||||
|
resources = _RESOURCES
|
||||||
|
|
||||||
|
__all__ = ["io", "ui", "resources"]
|
@ -7,7 +7,6 @@ import comfy.utils
|
|||||||
import comfy.sd
|
import comfy.sd
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
|
||||||
@io.comfytype(io_type="XYZ")
|
@io.comfytype(io_type="XYZ")
|
||||||
class XYZ(io.ComfyTypeIO):
|
class XYZ(io.ComfyTypeIO):
|
||||||
Type = tuple[int,str]
|
Type = tuple[int,str]
|
||||||
|
@ -33,7 +33,7 @@ from comfy_execution.validation import validate_node_input
|
|||||||
from comfy_execution.progress import get_progress_state, reset_progress_state, add_progress_handler, WebUIProgressHandler
|
from comfy_execution.progress import get_progress_state, reset_progress_state, add_progress_handler, WebUIProgressHandler
|
||||||
from comfy_execution.utils import CurrentNodeContext
|
from comfy_execution.utils import CurrentNodeContext
|
||||||
from comfy_api.internal import _ComfyNodeInternal, first_real_override, is_class, make_locked_method_func
|
from comfy_api.internal import _ComfyNodeInternal, first_real_override, is_class, make_locked_method_func
|
||||||
from comfy_api.v3 import io
|
from comfy_api.v3 import io, resources
|
||||||
|
|
||||||
|
|
||||||
class ExecutionResult(Enum):
|
class ExecutionResult(Enum):
|
||||||
@ -259,7 +259,7 @@ async def _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, f
|
|||||||
# NOTE: this is a mock of resource management; for local, just stores ResourcesLocal on node instance
|
# NOTE: this is a mock of resource management; for local, just stores ResourcesLocal on node instance
|
||||||
if hasattr(obj, "local_resources"):
|
if hasattr(obj, "local_resources"):
|
||||||
if obj.local_resources is None:
|
if obj.local_resources is None:
|
||||||
obj.local_resources = io.ResourcesLocal()
|
obj.local_resources = resources.ResourcesLocal()
|
||||||
class_clone.resources = obj.local_resources
|
class_clone.resources = obj.local_resources
|
||||||
# TODO: delete this when done testing mocking dynamic inputs
|
# TODO: delete this when done testing mocking dynamic inputs
|
||||||
for si in obj.SCHEMA.inputs:
|
for si in obj.SCHEMA.inputs:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user