MIF_E31231708/cv_app/api_app.py

26 lines
698 B
Python

"""
Compatibility wrapper.
API utama berada di ../ml/api_app.py. File ini dipertahankan agar command lama
`cd cv_app && uvicorn api_app:app` tetap memakai API terbaru.
"""
from importlib.util import module_from_spec, spec_from_file_location
from pathlib import Path
import sys
ML_DIR = Path(__file__).resolve().parent.parent / "ml"
ML_API_PATH = ML_DIR / "api_app.py"
if str(ML_DIR) not in sys.path:
sys.path.insert(0, str(ML_DIR))
spec = spec_from_file_location("confivoice_ml_api_app", ML_API_PATH)
if spec is None or spec.loader is None:
raise RuntimeError(f"Gagal memuat API utama: {ML_API_PATH}")
module = module_from_spec(spec)
spec.loader.exec_module(module)
app = module.app