41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import os
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
from fastapi import FastAPI
|
||
|
|
|
||
|
|
|
||
|
|
def create_app() -> FastAPI:
|
||
|
|
app = FastAPI(title="YG Fine-Tune Compute API")
|
||
|
|
|
||
|
|
@app.get("/health")
|
||
|
|
async def health_check() -> dict[str, str]:
|
||
|
|
return {
|
||
|
|
"status": "ok",
|
||
|
|
"compute_host_id": os.getenv("COMPUTE_HOST_ID", "unknown"),
|
||
|
|
}
|
||
|
|
|
||
|
|
@app.get("/api/v1/compute/health")
|
||
|
|
async def compute_health_check() -> dict[str, str | bool]:
|
||
|
|
data_root = Path(os.getenv("YG_FT_DATA_ROOT", "/data/yg-ft"))
|
||
|
|
llama_factory_home = Path(os.getenv("LLAMA_FACTORY_HOME", "/opt/LLaMA-Factory"))
|
||
|
|
return {
|
||
|
|
"status": "ok",
|
||
|
|
"compute_host_id": os.getenv("COMPUTE_HOST_ID", "unknown"),
|
||
|
|
"app_callback_enabled": os.getenv("ENABLE_APP_CALLBACK", "false").lower() == "true",
|
||
|
|
"data_root": str(data_root),
|
||
|
|
"data_root_exists": data_root.exists(),
|
||
|
|
"llama_factory_home": str(llama_factory_home),
|
||
|
|
"llama_factory_home_exists": llama_factory_home.exists(),
|
||
|
|
}
|
||
|
|
|
||
|
|
@app.get("/api/v1/compute/jobs")
|
||
|
|
async def list_jobs() -> dict[str, list[dict[str, str]]]:
|
||
|
|
return {"items": []}
|
||
|
|
|
||
|
|
return app
|
||
|
|
|
||
|
|
|
||
|
|
app = create_app()
|