MogensR commited on
Commit
a28f292
Β·
1 Parent(s): 9af7e52

Update core/app.py

Browse files
Files changed (1) hide show
  1. core/app.py +17 -8
core/app.py CHANGED
@@ -52,8 +52,14 @@ def _patched_get_type(schema):
52
  except Exception as e:
53
  logger.warning(f"Gradio patch failed: {e}")
54
  # ── Core config + components ─────────────────────────────────────────────────
55
- from config.app_config import get_config
56
- from core.exceptions import ModelLoadingError, VideoProcessingError
 
 
 
 
 
 
57
  from utils.hardware.device_manager import DeviceManager
58
  from utils.system.memory_manager import MemoryManager
59
  # Try to import the new split loaders first, fall back to old if needed
@@ -82,24 +88,27 @@ def _patched_get_type(schema):
82
  ]
83
  for import_path in two_stage_paths:
84
  try:
85
- if "processors" in import_path:
86
- from processors.two_stage import TwoStageProcessor, CHROMA_PRESETS # type: ignore
87
- else:
88
- from processing.two_stage.two_stage_processor import TwoStageProcessor, CHROMA_PRESETS # type: ignore
89
  TWO_STAGE_AVAILABLE = True
90
  TWO_STAGE_IMPORT_ORIGIN = import_path
91
  logger.info(f"Two-stage import OK ({import_path})")
92
  break
93
- except Exception:
 
94
  continue
95
  if not TWO_STAGE_AVAILABLE:
96
- logger.warning("Two-stage import FAILED from all paths")
97
  # ── Quiet startup self-check (async by default) ──────────────────────────────
98
  # Place the helper in tools/startup_selfcheck.py (with tools/__init__.py present)
99
  try:
100
  from tools.startup_selfcheck import schedule_startup_selfcheck
101
  except Exception:
102
  schedule_startup_selfcheck = None # graceful if the helper isn't shipped
 
 
 
 
 
103
  # ╔══════════════════════════════════════════════════════════════════════════╗
104
  # β•‘ VideoProcessor class β•‘
105
  # β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
 
52
  except Exception as e:
53
  logger.warning(f"Gradio patch failed: {e}")
54
  # ── Core config + components ─────────────────────────────────────────────────
55
+ try:
56
+ from config.app_config import get_config
57
+ except ImportError:
58
+ # Dummy if missing
59
+ class DummyConfig:
60
+ def to_dict(self):
61
+ return {}
62
+ get_config = lambda: DummyConfig()
63
  from utils.hardware.device_manager import DeviceManager
64
  from utils.system.memory_manager import MemoryManager
65
  # Try to import the new split loaders first, fall back to old if needed
 
88
  ]
89
  for import_path in two_stage_paths:
90
  try:
91
+ exec(f"from {import_path} import TwoStageProcessor, CHROMA_PRESETS")
 
 
 
92
  TWO_STAGE_AVAILABLE = True
93
  TWO_STAGE_IMPORT_ORIGIN = import_path
94
  logger.info(f"Two-stage import OK ({import_path})")
95
  break
96
+ except Exception as e:
97
+ TWO_STAGE_IMPORT_ERROR = str(e)
98
  continue
99
  if not TWO_STAGE_AVAILABLE:
100
+ logger.warning(f"Two-stage import FAILED from all paths: {TWO_STAGE_IMPORT_ERROR}")
101
  # ── Quiet startup self-check (async by default) ──────────────────────────────
102
  # Place the helper in tools/startup_selfcheck.py (with tools/__init__.py present)
103
  try:
104
  from tools.startup_selfcheck import schedule_startup_selfcheck
105
  except Exception:
106
  schedule_startup_selfcheck = None # graceful if the helper isn't shipped
107
+ # Dummy exceptions if core.exceptions not available
108
+ class ModelLoadingError(Exception):
109
+ pass
110
+ class VideoProcessingError(Exception):
111
+ pass
112
  # ╔══════════════════════════════════════════════════════════════════════════╗
113
  # β•‘ VideoProcessor class β•‘
114
  # β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•