diff --git a/comfy_api/v3/__init__.py b/comfy_api/v3/__init__.py index e69de29bb..b3a62e65a 100644 --- a/comfy_api/v3/__init__.py +++ b/comfy_api/v3/__init__.py @@ -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"] diff --git a/comfy_api/v3/_io.py b/comfy_api/v3/_io.py index ba6fe3c3a..0d7ac9974 100644 --- a/comfy_api/v3/_io.py +++ b/comfy_api/v3/_io.py @@ -24,7 +24,7 @@ from comfy.sd import StyleModel as StyleModel_ from comfy_api.input import VideoInput from comfy_api.internal import (_ComfyNodeInternal, classproperty, copy_class, first_real_override, is_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_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: ... -class IO: + +class _IO: 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) diff --git a/comfy_api/v3/_resources.py b/comfy_api/v3/_resources.py index 12c751275..a6bdda972 100644 --- a/comfy_api/v3/_resources.py +++ b/comfy_api/v3/_resources.py @@ -63,3 +63,10 @@ class ResourcesLocal(Resources): if default is not ...: return default raise Exception(f"Unsupported resource key type: {type(key)}") + + +class _RESOURCES: + ResourceKey = ResourceKey + TorchDictFolderFilename = TorchDictFolderFilename + Resources = Resources + ResourcesLocal = ResourcesLocal diff --git a/comfy_api/v3/_ui.py b/comfy_api/v3/_ui.py index d41d758d6..04e889f97 100644 --- a/comfy_api/v3/_ui.py +++ b/comfy_api/v3/_ui.py @@ -17,7 +17,7 @@ import folder_paths # used for image preview 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): @@ -488,3 +488,17 @@ class PreviewText(_UIOutput): def as_dict(self): 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 diff --git a/comfy_api/v3_01/__init__.py b/comfy_api/v3_01/__init__.py new file mode 100644 index 000000000..928f629a7 --- /dev/null +++ b/comfy_api/v3_01/__init__.py @@ -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"] diff --git a/comfy_extras/nodes_v3_test.py b/comfy_extras/nodes_v3_test.py index b8e5e2ae0..c0816ebe0 100644 --- a/comfy_extras/nodes_v3_test.py +++ b/comfy_extras/nodes_v3_test.py @@ -7,7 +7,6 @@ import comfy.utils import comfy.sd import asyncio - @io.comfytype(io_type="XYZ") class XYZ(io.ComfyTypeIO): Type = tuple[int,str] diff --git a/execution.py b/execution.py index c6c853a99..608006467 100644 --- a/execution.py +++ b/execution.py @@ -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.utils import CurrentNodeContext 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): @@ -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 if hasattr(obj, "local_resources"): if obj.local_resources is None: - obj.local_resources = io.ResourcesLocal() + obj.local_resources = resources.ResourcesLocal() class_clone.resources = obj.local_resources # TODO: delete this when done testing mocking dynamic inputs for si in obj.SCHEMA.inputs: