File size: 1,615 Bytes
f884e6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
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."
        )