Moved sn0w.py to root
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
from .src.dynamic_lora_loader import generate_lora_node_class
|
||||
from .src.sn0w import ConfigReader, Logger
|
||||
from .sn0w import ConfigReader, Logger
|
||||
|
||||
from .src.find_resolution import FindResolutionNode
|
||||
from .src.lora_selector import LoraSelectorNode
|
||||
|
||||
+3
-23
@@ -3,31 +3,11 @@ import json
|
||||
import torch
|
||||
|
||||
class ConfigReader:
|
||||
_config = None
|
||||
|
||||
@classmethod
|
||||
def load_config(cls):
|
||||
if cls._config is None:
|
||||
# Get the directory of the current file
|
||||
current_file_path = os.path.realpath(__file__)
|
||||
# Navigate up to the parent directory of the current file
|
||||
parent_dir = os.path.dirname(os.path.dirname(current_file_path))
|
||||
# Construct the path to the 'config.json' file located in the parent directory
|
||||
config_path = os.path.join(parent_dir, 'config.json')
|
||||
|
||||
try:
|
||||
with open(config_path, 'r') as file:
|
||||
cls._config = json.load(file)
|
||||
except FileNotFoundError:
|
||||
print(f"Configuration file not found at {config_path}. Using default settings.")
|
||||
cls._config = {} # Use an empty dict as a fallback
|
||||
return cls._config
|
||||
|
||||
@staticmethod
|
||||
def get_setting(setting_id, default=None):
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
# Construct the relative path
|
||||
relative_path = '../../../user/default/comfy.settings.json'
|
||||
relative_path = '../../user/default/comfy.settings.json'
|
||||
# Combine paths and normalize it
|
||||
file_path = os.path.abspath(os.path.join(current_dir, relative_path))
|
||||
try:
|
||||
@@ -35,10 +15,10 @@ class ConfigReader:
|
||||
settings = json.load(file)
|
||||
return settings.get(setting_id, default)
|
||||
except FileNotFoundError:
|
||||
print(f"Local configuration file not found at {file_path}.")
|
||||
Logger.print_sn0w(f"Local configuration file not found at {file_path}.", "\033[0;33m")
|
||||
return default
|
||||
except json.JSONDecodeError:
|
||||
print(f"Error decoding JSON from {file_path}.")
|
||||
Logger.print_sn0w(f"Error decoding JSON from {file_path}.", "\033[0;31m")
|
||||
return default
|
||||
|
||||
class Logger:
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import json
|
||||
import random
|
||||
from .sn0w import ConfigReader, Logger
|
||||
from ..sn0w import ConfigReader, Logger
|
||||
|
||||
class CharacterSelectNode:
|
||||
# Initialize class variables
|
||||
|
||||
@@ -2,7 +2,6 @@ import os
|
||||
import folder_paths
|
||||
from nodes import LoraLoader
|
||||
from pathlib import Path
|
||||
from .sn0w import ConfigReader, Logger
|
||||
|
||||
def generate_lora_node_class(lora_type, required_folders):
|
||||
class DynamicLoraNode:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import folder_paths
|
||||
from nodes import LoraLoader
|
||||
from pathlib import Path
|
||||
from .sn0w import ConfigReader
|
||||
|
||||
class LoraLora15Node:
|
||||
@classmethod
|
||||
|
||||
@@ -3,7 +3,7 @@ import re
|
||||
import time
|
||||
import folder_paths
|
||||
from nodes import LoraLoader
|
||||
from .sn0w import Logger, Utility, ConfigReader
|
||||
from ..sn0w import Logger, Utility, ConfigReader
|
||||
|
||||
class LoadLoraFolderNode:
|
||||
logger = Logger()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import folder_paths
|
||||
from nodes import LoraLoader
|
||||
from pathlib import Path
|
||||
from .sn0w import ConfigReader
|
||||
|
||||
class LoraLoraXLNode:
|
||||
@classmethod
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
from nodes import KSampler, KSamplerAdvanced, VAEDecode, VAEEncode, EmptyLatentImage, LoraLoader, ImageScaleBy, CLIPTextEncode
|
||||
from .sn0w import Utility
|
||||
from ..sn0w import Utility
|
||||
from comfy_extras.nodes_upscale_model import ImageUpscaleWithModel
|
||||
import comfy.samplers
|
||||
import folder_paths
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import os
|
||||
import numpy as np
|
||||
import torch
|
||||
from PIL import Image
|
||||
|
||||
class FilmGrain:
|
||||
def __init__(self):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import re
|
||||
from .sn0w import ConfigReader, Logger
|
||||
from ..sn0w import ConfigReader, Logger
|
||||
|
||||
class CombineStringNode:
|
||||
logger = Logger()
|
||||
|
||||
Reference in New Issue
Block a user