Initial setup for v3. Disabled, and will stay disabled until a lot of other stuff is done...

This commit is contained in:
Shanoah Alkire
2025-09-29 03:13:51 -07:00
parent a232589e1a
commit 306fdc8f60
4 changed files with 267 additions and 24 deletions
+37 -22
View File
@@ -1,11 +1,21 @@
import os
SAGEUTILS_PRINT_TIMING = False # Set to True to enable timing report
# Print timing report if enabled via environment variable
if os.environ.get('SAGEUTILS_PRINT_TIMING', '').lower() in ('1', 'true', 'yes'):
SAGEUTILS_PRINT_TIMING = True
# Initialize performance timing as early as possible
from .utils.performance_timer import python_timer, log_init
log_init("IMPORTS_START")
# Set to 1 for v1 nodes, 3 for v3 nodes.
# Right now, v3 nodes aren't ready for use.
NODE_VERSION = os.environ.get('SAGEUTILS_NODE_VERSION', '1')
# Import all node classes
from .nodes_v1 import *
if NODE_VERSION == '1':
from .nodes_v1 import *
# Import utility functions and objects
from .utils import cache, config_manager
@@ -54,32 +64,33 @@ except Exception as e:
WEB_DIRECTORY = "./js"
if llm.OLLAMA_AVAILABLE:
LLM_CLASS_MAPPINGS = LLM_CLASS_MAPPINGS | OLLAMA_CLASS_MAPPINGS
if NODE_VERSION == '1':
if llm.OLLAMA_AVAILABLE:
LLM_CLASS_MAPPINGS = LLM_CLASS_MAPPINGS | OLLAMA_CLASS_MAPPINGS
if llm.LMSTUDIO_AVAILABLE:
LLM_CLASS_MAPPINGS = LLM_CLASS_MAPPINGS | LMSTUDIO_CLASS_MAPPINGS
if llm.LMSTUDIO_AVAILABLE:
LLM_CLASS_MAPPINGS = LLM_CLASS_MAPPINGS | LMSTUDIO_CLASS_MAPPINGS
# A dictionary that contains all nodes you want to export with their names
# NOTE: names should be globally unique
NODE_CLASS_MAPPINGS |= NODE_CLASS_MAPPINGS | LLM_CLASS_MAPPINGS
# A dictionary that contains all nodes you want to export with their names
# NOTE: names should be globally unique
NODE_CLASS_MAPPINGS |= NODE_CLASS_MAPPINGS | LLM_CLASS_MAPPINGS
if ENABLE_TRAINING_NODES:
NODE_CLASS_MAPPINGS = NODE_CLASS_MAPPINGS | TRAINING_CLASS_MAPPINGS
if ENABLE_TRAINING_NODES:
NODE_CLASS_MAPPINGS = NODE_CLASS_MAPPINGS | TRAINING_CLASS_MAPPINGS
if llm.OLLAMA_AVAILABLE:
LLM_NAME_MAPPINGS = LLM_NAME_MAPPINGS | OLLAMA_NAME_MAPPINGS
if llm.OLLAMA_AVAILABLE:
LLM_NAME_MAPPINGS = LLM_NAME_MAPPINGS | OLLAMA_NAME_MAPPINGS
if llm.LMSTUDIO_AVAILABLE:
LLM_NAME_MAPPINGS = LLM_NAME_MAPPINGS | LMSTUDIO_NAME_MAPPINGS
if llm.LMSTUDIO_AVAILABLE:
LLM_NAME_MAPPINGS = LLM_NAME_MAPPINGS | LMSTUDIO_NAME_MAPPINGS
# A dictionary that contains the friendly/human readable titles for the nodes
NODE_DISPLAY_NAME_MAPPINGS = NODE_DISPLAY_NAME_MAPPINGS | LLM_NAME_MAPPINGS
# A dictionary that contains the friendly/human readable titles for the nodes
NODE_DISPLAY_NAME_MAPPINGS = NODE_DISPLAY_NAME_MAPPINGS | LLM_NAME_MAPPINGS
if ENABLE_TRAINING_NODES:
NODE_DISPLAY_NAME_MAPPINGS = NODE_DISPLAY_NAME_MAPPINGS | TRAINING_NAME_MAPPINGS
if ENABLE_TRAINING_NODES:
NODE_DISPLAY_NAME_MAPPINGS = NODE_DISPLAY_NAME_MAPPINGS | TRAINING_NAME_MAPPINGS
log_init("NODE_MAPPINGS_CREATED")
log_init("NODE_MAPPINGS_CREATED")
# Complete initialization timing
from .utils.performance_timer import complete_initialization, print_timing_report
@@ -92,8 +103,12 @@ try:
except Exception as e:
print(f"Warning: Failed to start background LLM cache population: {e}")
# Print timing report if enabled via environment variable
if os.environ.get('SAGEUTILS_PRINT_TIMING', '').lower() in ('1', 'true', 'yes'):
# Print timing report if enabled.
if SAGEUTILS_PRINT_TIMING:
print_timing_report()
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', 'WEB_DIRECTORY']
if NODE_VERSION == '1':
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', 'WEB_DIRECTORY']
else:
from .nodes_v3 import *
__all__ = ['SageExtension', 'WEB_DIRECTORY']
+208
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -1,9 +1,9 @@
# Initialize performance timing as early as possible
from .utils.performance_timer import log_init
# Import all node classes
from .nodes import *
log_init("NODES_IMPORTED")
log_init("V1_NODES_IMPORTED")
# Currently, we have to have two mappings: one for the class names and one for the display names.
+20
View File
@@ -0,0 +1,20 @@
# No real reason v1 and v3 nodes can't coexist, but the loader loads one of the other, so I guess I am too.
# Yay, twice as much work to maintain!
from comfy_api.latest import io, ComfyExtension
from typing_extensions import override
from .utils.performance_timer import log_init
from .nodes.text_v3 import *
NODE_LIST = []
NODE_LIST = NODE_LIST + TEXT_NODES
class SageExtension(ComfyExtension):
@override
async def get_node_list(self) -> list[type[io.ComfyNode]]:
return NODE_LIST
async def comfy_entrypoint() -> SageExtension:
return SageExtension()
log_init("V3_NODES_IMPORTED")