fixed the rules engine not being pulled from the application state after refactor earlier

This commit is contained in:
2025-08-22 10:52:35 -05:00
parent 469334d137
commit dbd7cb31c7
2 changed files with 8 additions and 24 deletions

View File

@@ -48,19 +48,8 @@ class Browser:
lazily-loaded singleton factory `get_browser()`.
"""
def __init__(self, storage_dir: Optional[Path] = None) -> None:
"""
Args:
storage_dir: Base directory for run artifacts. Defaults to settings.sandbox.storage
(typically /data) if not provided.
"""
if storage_dir is None:
try:
# Prefer your settings models configured storage path
storage_dir = Path(settings.sandbox.storage)
except Exception:
storage_dir = Path("/data")
def __init__(self) -> None:
storage_dir = Path("/data")
self.storage_dir: Path = storage_dir
# -----------------------------------------------------------------------
@@ -69,15 +58,13 @@ class Browser:
@staticmethod
def _get_rule_engine():
"""
Retrieve the rules engine instance from the Flask application config.
Retrieve the rules engine instance from the application state.
Returns:
RuleEngine or None: The engine if available, or None if not configured.
"""
try:
return current_app.config.get("RULE_ENGINE")
except Exception:
return None
from app.state import get_rules_engine
return get_rules_engine()
@staticmethod
def _summarize_results(results: List[Dict[str, Any]]) -> Dict[str, int]:
@@ -537,14 +524,11 @@ except Exception:
@singleton_loader
def get_browser(storage_dir: Optional[Path] = None) -> Browser:
def get_browser() -> Browser:
"""
Lazily construct and cache a singleton Browser instance.
Args:
storage_dir: Optional override for artifact base directory.
Returns:
Browser: The singleton instance.
"""
return Browser(storage_dir=storage_dir)
return Browser()