refactor: unify standalone mode check using environment variable

This commit is contained in:
Will Miao
2025-09-21 22:45:11 +08:00
parent 7e20f738fb
commit fec85bcc08
8 changed files with 15 additions and 12 deletions

View File

@@ -3,12 +3,11 @@ import platform
import folder_paths # type: ignore
from typing import List
import logging
import sys
import json
import urllib.parse
# Check if running in standalone mode
standalone_mode = 'nodes' not in sys.modules
# Use an environment variable to control standalone mode
standalone_mode = os.environ.get("HF_HUB_DISABLE_TELEMETRY", "0") == "0"
logger = logging.getLogger(__name__)

View File

@@ -1,9 +1,7 @@
import os
import importlib
import sys
# Check if running in standalone mode
standalone_mode = 'nodes' not in sys.modules
standalone_mode = os.environ.get("HF_HUB_DISABLE_TELEMETRY", "0") == "0"
if not standalone_mode:
from .metadata_hook import MetadataHook

View File

@@ -1,9 +1,9 @@
import json
import sys
import os
from .constants import IMAGES
# Check if running in standalone mode
standalone_mode = 'nodes' not in sys.modules
standalone_mode = os.environ.get("HF_HUB_DISABLE_TELEMETRY", "0") == "0"
from .constants import MODELS, PROMPTS, SAMPLING, LORAS, SIZE, IS_SAMPLER

View File

@@ -18,7 +18,7 @@ from ..services.websocket_manager import ws_manager
from ..services.downloader import get_downloader
logger = logging.getLogger(__name__)
standalone_mode = 'nodes' not in sys.modules
standalone_mode = os.environ.get("HF_HUB_DISABLE_TELEMETRY", "0") == "0"
# Node registry for tracking active workflow nodes
class NodeRegistry:

View File

@@ -21,7 +21,7 @@ from ..services.server_i18n import server_i18n
from ..config import config
# Check if running in standalone mode
standalone_mode = 'nodes' not in sys.modules
standalone_mode = os.environ.get("HF_HUB_DISABLE_TELEMETRY", "0") == "0"
from ..services.service_registry import ServiceRegistry # Add ServiceRegistry import
from ..services.downloader import get_downloader

View File

@@ -1,6 +1,5 @@
import os
import json
import sys
import time
import asyncio
import logging
@@ -12,7 +11,7 @@ from ..config import config
from ..services.service_registry import ServiceRegistry
# Check if running in standalone mode
standalone_mode = 'nodes' not in sys.modules
standalone_mode = os.environ.get("HF_HUB_DISABLE_TELEMETRY", "0") == "0"
if not standalone_mode:
from ..metadata_collector.metadata_registry import MetadataRegistry