Spaces:
Sleeping
Sleeping
| """ | |
| Wrapper module for enhanced evaluation to support HF Spaces deployment. | |
| This module attempts to import the real implementation from common locations | |
| (`../..` project-root `evaluation/`, or current working directory `evaluation/`). | |
| If found, it re-exports the `run_enhanced_evaluation` function. Otherwise it | |
| exposes a stub that raises ImportError with a clear message. | |
| """ | |
| import importlib.util | |
| import os | |
| from typing import Optional | |
| def _load_from_candidate(candidate_dir: str) -> Optional[object]: | |
| path = os.path.join(candidate_dir, "enhanced_evaluation.py") | |
| if not os.path.exists(path): | |
| return None | |
| spec = importlib.util.spec_from_file_location("enhanced_evaluation_impl", path) | |
| if spec is None or spec.loader is None: | |
| return None | |
| mod = importlib.util.module_from_spec(spec) | |
| spec.loader.exec_module(mod) | |
| return mod | |
| _candidates = [ | |
| os.path.join(os.path.dirname(__file__), "..", "..", "evaluation"), | |
| os.path.join(os.path.dirname(__file__), "..", "evaluation"), | |
| os.path.join(os.getcwd(), "evaluation"), | |
| ] | |
| _impl = None | |
| for c in _candidates: | |
| mod = _load_from_candidate(os.path.abspath(c)) | |
| if mod: | |
| _impl = mod | |
| break | |
| if _impl is not None and hasattr(_impl, "run_enhanced_evaluation"): | |
| run_enhanced_evaluation = getattr(_impl, "run_enhanced_evaluation") | |
| else: | |
| def run_enhanced_evaluation(*args, **kwargs): | |
| raise ImportError( | |
| "enhanced_evaluation implementation not found in deployment. " | |
| "Ensure the repository 'evaluation/enhanced_evaluation.py' is present in the container." | |
| ) | |