Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ app_config.json
starter.yaml
CLAUDE.md
.codex
.superpowers/
ui/.pnp.*
ui/.yarn/
*.log
docs/superpowers
*_api_key.*
codex_home/
codex_home/
40 changes: 40 additions & 0 deletions api/app/controllers/obtainer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from __future__ import annotations

from pathlib import Path

from fastapi import APIRouter

from ..models.body import response_body
from ..utils.obtainer.monitor import build_lake_monitor, probe_embedding_health

router = APIRouter(tags=["obtainer"])

REPO_ROOT = Path(__file__).resolve().parents[3]


def _resolve_lake_path(lake: str | None) -> Path:
raw = lake or ".loopai/lake.yaml"
path = Path(raw).expanduser()
if not path.is_absolute():
path = REPO_ROOT / path
if path.suffix in {".yaml", ".yml"} and not path.exists():
raise FileNotFoundError(f"Lake config not found: {path}")
return path


@router.get("/lake/monitor", operation_id="getObtainerLakeMonitor", summary="获取 Obtainer 数据湖监控数据")
async def get_lake_monitor(lake: str | None = None):
try:
data = build_lake_monitor(lake=_resolve_lake_path(lake))
except Exception as exc:
return response_body(code=400, status="error", message=str(exc))()
return response_body(data=data)()


@router.get("/lake/embedding_health", operation_id="getObtainerEmbeddingHealth", summary="探测 Obtainer embedding 服务状态")
async def get_embedding_health(lake: str | None = None, timeout_seconds: float = 3.0):
try:
data = probe_embedding_health(lake=_resolve_lake_path(lake), timeout_seconds=timeout_seconds)
except Exception as exc:
return response_body(code=400, status="error", message=str(exc))()
return response_body(data=data)()
2 changes: 2 additions & 0 deletions api/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .controllers.task import router as task_router
from .controllers.train import router as train_router
from .controllers.resource import router as resource_router
from .controllers.obtainer import router as obtainer_router

import os
import signal
Expand Down Expand Up @@ -65,6 +66,7 @@ async def lifespan(app: FastAPI):
app.include_router(task_router, prefix="/task", tags=["task"])
app.include_router(train_router, prefix="/train", tags=["train"])
app.include_router(resource_router, prefix="/resource", tags=["resource"])
app.include_router(obtainer_router, prefix="/obtainer", tags=["obtainer"])

app.mount(
"/assets",
Expand Down
1 change: 1 addition & 0 deletions api/app/utils/obtainer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Obtainer lake monitor utilities."""
Loading