Merge pull request #4 from ru4ls/develop

refactor: Restructure project for better organization and maintainability

Reorganized files into logical modules (core, generators, vace, config)
Renamed files to follow standard Python naming conventions
Updated all import statements to reflect new structure
Added proper init.py files for each module
Updated README.md to reference new file locations
Maintained backward compatibility with wan_nodes.py
Preserved all functionality while improving code organization
This commit is contained in:
ru4ls
2025-09-12 19:00:21 +07:00
committed by GitHub
18 changed files with 67 additions and 49 deletions
+3 -3
View File
@@ -28,7 +28,7 @@ This is a direct integration with Alibaba Cloud's Model Studio service, not a th
## Regional Support
This node supports both international and Mainland China Alibaba Cloud regions. By default, it uses the international region endpoints, but you can easily switch to Mainland China endpoints by modifying the variables in `wan_base.py`:
This node supports both international and Mainland China Alibaba Cloud regions. By default, it uses the international region endpoints, but you can easily switch to Mainland China endpoints by modifying the variables in `core/base.py`:
- **International Region** (default):
- Video POST: `https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis`
@@ -42,11 +42,11 @@ This node supports both international and Mainland China Alibaba Cloud regions.
- T2I POST: `https://dashscope.aliyuncs.com/api/v1/services/aigc/text2image/image-synthesis`
- GET: `https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}`
To switch regions, simply modify the `API_ENDPOINT_POST_VIDEO`, `API_ENDPOINT_POST_II2V`, `API_ENDPOINT_POST_T2I`, and `API_ENDPOINT_GET` variables in `wan_base.py` to the corresponding Mainland China endpoints listed above.
To switch regions, simply modify the `API_ENDPOINT_POST_VIDEO`, `API_ENDPOINT_POST_II2V`, `API_ENDPOINT_POST_T2I`, and `API_ENDPOINT_GET` variables in `core/base.py` to the corresponding Mainland China endpoints listed above.
## Centralized Endpoint Management
All API endpoints are centrally managed in the `wan_base.py` file, making it easy to maintain and switch between regions. This approach ensures consistency across all nodes and simplifies future updates. The centralized management includes:
All API endpoints are centrally managed in the `core/base.py` file, making it easy to maintain and switch between regions. This approach ensures consistency across all nodes and simplifies future updates. The centralized management includes:
- `API_ENDPOINT_POST_VIDEO`: For general video generation nodes (I2V, T2V, VACE)
- `API_ENDPOINT_POST_II2V`: For image-to-video with first/last frames (II2V)
+10 -10
View File
@@ -1,17 +1,17 @@
"""
ComfyUI_Wan - A custom node for ComfyUI that integrates Wan models
for text-to-image, image-to-video, and text-to-video generation.
for text-to-image, image-to-video, text-to-video, first-last-frame-tovideo, and VACE generation.
"""
from .wan_t2i import WanT2IGenerator
from .wan_i2v import WanI2VGenerator
from .wan_t2v import WanT2VGenerator
from .wan_ii2v import WanII2VGenerator
from .wan_vace_image_reference import WanVACEImageReference
from .wan_vace_video_repainting import WanVACEVideoRepainting
from .wan_vace_video_edit import WanVACEVideoEdit
from .wan_vace_video_extension import WanVACEVideoExtension
from .wan_vace_video_outpainting import WanVACEVideoOutpainting
from .generators.t2i import WanT2IGenerator
from .generators.i2v import WanI2VGenerator
from .generators.t2v import WanT2VGenerator
from .generators.ii2v import WanII2VGenerator
from .vace.image_reference import WanVACEImageReference
from .vace.video_repainting import WanVACEVideoRepainting
from .vace.video_edit import WanVACEVideoEdit
from .vace.video_extension import WanVACEVideoExtension
from .vace.video_outpainting import WanVACEVideoOutpainting
NODE_CLASS_MAPPINGS = {
"WanT2IGenerator": WanT2IGenerator,
+1
View File
@@ -0,0 +1 @@
# Configuration module
+3
View File
@@ -0,0 +1,3 @@
from .base import WanAPIBase, COMFYUI_AVAILABLE
__all__ = ['WanAPIBase', 'COMFYUI_AVAILABLE']
View File
+6
View File
@@ -0,0 +1,6 @@
from .t2i import WanT2IGenerator
from .i2v import WanI2VGenerator
from .t2v import WanT2VGenerator
from .ii2v import WanII2VGenerator
__all__ = ['WanT2IGenerator', 'WanI2VGenerator', 'WanT2VGenerator', 'WanII2VGenerator']
+3 -3
View File
@@ -12,7 +12,7 @@ import pathlib
from datetime import datetime
# Import the base class and COMFYUI_AVAILABLE flag
from .wan_base import WanAPIBase, COMFYUI_AVAILABLE
from ..core.base import WanAPIBase, COMFYUI_AVAILABLE
# Try to import folder_paths if available
try:
@@ -39,7 +39,7 @@ class WanI2VGenerator(WanAPIBase):
def __init__(self):
super().__init__()
# Use the centralized API endpoint from the base class
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py
self.api_url = self.API_ENDPOINT_POST_VIDEO
@classmethod
@@ -185,7 +185,7 @@ class WanI2VGenerator(WanAPIBase):
import time
# URL for querying task results
# To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_GET in core/base.py
query_url = self.API_ENDPOINT_GET.format(task_id=task_id)
headers = {
+3 -3
View File
@@ -12,7 +12,7 @@ import pathlib
from datetime import datetime
# Import the base class and COMFYUI_AVAILABLE flag
from .wan_base import WanAPIBase, COMFYUI_AVAILABLE
from ..core.base import WanAPIBase, COMFYUI_AVAILABLE
# Try to import folder_paths if available
try:
@@ -36,7 +36,7 @@ class WanII2VGenerator(WanAPIBase):
def __init__(self):
super().__init__()
# Use the centralized API endpoint from the base class
# To use Mainland China region, modify API_ENDPOINT_POST_II2V in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_POST_II2V in core/base.py
self.api_url = self.API_ENDPOINT_POST_II2V
@classmethod
@@ -186,7 +186,7 @@ class WanII2VGenerator(WanAPIBase):
import time
# URL for querying task results
# To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_GET in core/base.py
query_url = self.API_ENDPOINT_GET.format(task_id=task_id)
headers = {
+3 -3
View File
@@ -11,7 +11,7 @@ import sys
import pathlib
# Import the base class
from .wan_base import WanAPIBase, COMFYUI_AVAILABLE
from ..core.base import WanAPIBase, COMFYUI_AVAILABLE
# Try to import folder_paths if available
try:
@@ -43,7 +43,7 @@ class WanT2IGenerator(WanAPIBase):
def __init__(self):
super().__init__()
# Use the centralized API endpoint from the base class
# To use Mainland China region, modify API_ENDPOINT_POST_T2I in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_POST_T2I in core/base.py
self.api_url = self.API_ENDPOINT_POST_T2I
self.model = "wan2.2-t2i-flash" # Using Wan Speed Edition as default
@@ -187,7 +187,7 @@ class WanT2IGenerator(WanAPIBase):
import time
# URL for querying task results
# To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_GET in core/base.py
query_url = self.API_ENDPOINT_GET.format(task_id=task_id)
headers = {
+3 -3
View File
@@ -12,7 +12,7 @@ import pathlib
from datetime import datetime
# Import the base class and COMFYUI_AVAILABLE flag
from .wan_base import WanAPIBase, COMFYUI_AVAILABLE
from ..core.base import WanAPIBase, COMFYUI_AVAILABLE
# Try to import folder_paths if available
try:
@@ -37,7 +37,7 @@ class WanT2VGenerator(WanAPIBase):
def __init__(self):
super().__init__()
# Use the centralized API endpoint from the base class
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py
self.api_url = self.API_ENDPOINT_POST_VIDEO
@classmethod
@@ -199,7 +199,7 @@ class WanT2VGenerator(WanAPIBase):
import time
# URL for querying task results
# To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_GET in core/base.py
query_url = self.API_ENDPOINT_GET.format(task_id=task_id)
headers = {
+8
View File
@@ -0,0 +1,8 @@
from .image_reference import WanVACEImageReference
from .video_repainting import WanVACEVideoRepainting
from .video_edit import WanVACEVideoEdit
from .video_extension import WanVACEVideoExtension
from .video_outpainting import WanVACEVideoOutpainting
__all__ = ['WanVACEImageReference', 'WanVACEVideoRepainting', 'WanVACEVideoEdit',
'WanVACEVideoExtension', 'WanVACEVideoOutpainting']
@@ -16,7 +16,7 @@ import pathlib
from datetime import datetime
# Import the base class and COMFYUI_AVAILABLE flag
from .wan_base import WanAPIBase, COMFYUI_AVAILABLE
from ..core.base import WanAPIBase, COMFYUI_AVAILABLE
# Try to import folder_paths if available
try:
@@ -44,7 +44,7 @@ class WanVACEImageReference(WanAPIBase):
def __init__(self):
super().__init__()
# Use the centralized API endpoint from the base class
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py
self.api_url = self.API_ENDPOINT_POST_VIDEO
@classmethod
@@ -222,7 +222,7 @@ class WanVACEImageReference(WanAPIBase):
import time
# URL for querying task results
# To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_GET in core/base.py
query_url = self.API_ENDPOINT_GET.format(task_id=task_id)
headers = {
@@ -16,7 +16,7 @@ import pathlib
from datetime import datetime
# Import the base class and COMFYUI_AVAILABLE flag
from .wan_base import WanAPIBase, COMFYUI_AVAILABLE
from ..core.base import WanAPIBase, COMFYUI_AVAILABLE
# Try to import folder_paths if available
try:
@@ -66,7 +66,7 @@ class WanVACEVideoEdit(WanAPIBase):
def __init__(self):
super().__init__()
# Use the centralized API endpoint from the base class
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py
self.api_url = self.API_ENDPOINT_POST_VIDEO
@classmethod
@@ -273,7 +273,7 @@ class WanVACEVideoEdit(WanAPIBase):
import time
# URL for querying task results
# To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_GET in core/base.py
query_url = self.API_ENDPOINT_GET.format(task_id=task_id)
headers = {
@@ -16,7 +16,7 @@ import pathlib
from datetime import datetime
# Import the base class and COMFYUI_AVAILABLE flag
from .wan_base import WanAPIBase, COMFYUI_AVAILABLE
from ..core.base import WanAPIBase, COMFYUI_AVAILABLE
# Try to import folder_paths if available
try:
@@ -44,7 +44,7 @@ class WanVACEVideoExtension(WanAPIBase):
def __init__(self):
super().__init__()
# Use the centralized API endpoint from the base class
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py
self.api_url = self.API_ENDPOINT_POST_VIDEO
@classmethod
@@ -227,7 +227,7 @@ class WanVACEVideoExtension(WanAPIBase):
import time
# URL for querying task results
# To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_GET in core/base.py
query_url = self.API_ENDPOINT_GET.format(task_id=task_id)
headers = {
@@ -16,7 +16,7 @@ import pathlib
from datetime import datetime
# Import the base class and COMFYUI_AVAILABLE flag
from .wan_base import WanAPIBase, COMFYUI_AVAILABLE
from ..core.base import WanAPIBase, COMFYUI_AVAILABLE
# Try to import folder_paths if available
try:
@@ -35,7 +35,7 @@ class WanVACEVideoOutpainting(WanAPIBase):
def __init__(self):
super().__init__()
# Use the centralized API endpoint from the base class
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py
self.api_url = self.API_ENDPOINT_POST_VIDEO
@classmethod
@@ -210,7 +210,7 @@ class WanVACEVideoOutpainting(WanAPIBase):
import time
# URL for querying task results
# To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_GET in core/base.py
query_url = self.API_ENDPOINT_GET.format(task_id=task_id)
headers = {
@@ -16,7 +16,7 @@ import pathlib
from datetime import datetime
# Import the base class and COMFYUI_AVAILABLE flag
from .wan_base import WanAPIBase, COMFYUI_AVAILABLE
from ..core.base import WanAPIBase, COMFYUI_AVAILABLE
# Try to import folder_paths if available
try:
@@ -43,7 +43,7 @@ class WanVACEVideoRepainting(WanAPIBase):
def __init__(self):
super().__init__()
# Use the centralized API endpoint from the base class
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_POST_VIDEO in core/base.py
self.api_url = self.API_ENDPOINT_POST_VIDEO
@classmethod
@@ -208,7 +208,7 @@ class WanVACEVideoRepainting(WanAPIBase):
import time
# URL for querying task results
# To use Mainland China region, modify API_ENDPOINT_GET in wan_base.py
# To use Mainland China region, modify API_ENDPOINT_GET in core/base.py
query_url = self.API_ENDPOINT_GET.format(task_id=task_id)
headers = {
+9 -9
View File
@@ -2,15 +2,15 @@
Backward compatibility module - imports all Wan nodes from their separate modules.
"""
from .wan_t2i import WanT2IGenerator
from .wan_i2v import WanI2VGenerator
from .wan_t2v import WanT2VGenerator
from .wan_ii2v import WanII2VGenerator
from .wan_vace_image_reference import WanVACEImageReference
from .wan_vace_video_repainting import WanVACEVideoRepainting
from .wan_vace_video_edit import WanVACEVideoEdit
from .wan_vace_video_extension import WanVACEVideoExtension
from .wan_vace_video_outpainting import WanVACEVideoOutpainting
from .generators.t2i import WanT2IGenerator
from .generators.i2v import WanI2VGenerator
from .generators.t2v import WanT2VGenerator
from .generators.ii2v import WanII2VGenerator
from .vace.image_reference import WanVACEImageReference
from .vace.video_repainting import WanVACEVideoRepainting
from .vace.video_edit import WanVACEVideoEdit
from .vace.video_extension import WanVACEVideoExtension
from .vace.video_outpainting import WanVACEVideoOutpainting
__all__ = ['WanT2IGenerator', 'WanI2VGenerator', 'WanT2VGenerator', 'WanII2VGenerator',
'WanVACEImageReference', 'WanVACEVideoRepainting', 'WanVACEVideoEdit',