File size: 905 Bytes
c6abe34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45dcdd6
 
 
 
 
 
 
 
 
 
 
 
 
c6abe34
 
 
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
import os
import logging
from app.config import get_settings

logger = logging.getLogger("test")

settings = get_settings()

_BACKEND_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(f"DEBUG: _BACKEND_ROOT = {_BACKEND_ROOT}")

def _resolve_model_path(path: str) -> str:
    if os.path.isabs(path):
        return path
    
    # Anchor to the backend root (parent of personal_analysis/)
    candidate = os.path.abspath(os.path.join(_BACKEND_ROOT, path))
    
    if os.path.exists(candidate):
        return candidate

    # Robust fallback for 'DON'T TOUCH' mangled environments
    if "OKIDI-DONT TOUCH" in candidate:
        healed = candidate.replace("OKIDI-DONT TOUCH", "OKIDI-DON'T TOUCH")
        if os.path.exists(healed):
            return healed
            
    return candidate

rim = _resolve_model_path(settings.swish_ball_rim_model)
print(f"FINAL RESOLVED: {rim}")