Claude übernimmt

This commit is contained in:
chk
2026-06-08 20:34:43 +02:00
parent 53db55ba36
commit 4358857cf2
9 changed files with 515 additions and 12 deletions

View File

@@ -5,7 +5,7 @@ from .server import create_app
def start_server(
robot_json=None,
host: str = "0.0.0.0",
port: int = 8080,
port: int = 8446,
) -> None:
import uvicorn
app = create_app(robot_json=robot_json)

View File

@@ -8,7 +8,7 @@ def main() -> None:
ap = argparse.ArgumentParser(description="approbot-pipeline REST-API starten")
ap.add_argument("--robot", default=None, help="Pfad zu robot.json")
ap.add_argument("--host", default="0.0.0.0")
ap.add_argument("--port", type=int, default=8080)
ap.add_argument("--port", type=int, default=8446)
args = ap.parse_args()
start_server(robot_json=args.robot, host=args.host, port=args.port)

View File

@@ -19,6 +19,20 @@ def create_app(robot_json: str | Path | None = None) -> FastAPI:
global _robot_json
if robot_json:
_robot_json = Path(robot_json).resolve()
# Frühe, klare Warnung statt kryptischem 500 zur Laufzeit.
# Häufige Falle: Docker legt für einen fehlenden Bind-Mount-Pfad
# ein leeres VERZEICHNIS an — dann ist _robot_json zwar vorhanden,
# aber keine Datei.
if not _robot_json.is_file():
import warnings
grund = "ist ein Verzeichnis" if _robot_json.is_dir() else "existiert nicht"
warnings.warn(
f"robot.json {grund}: {_robot_json}. "
f"/v1/config liefert 404, /v1/estimate verlangt einen robot_json-Upload. "
f"Bei Docker: liegt die Datei wirklich am gemounteten Host-Pfad?",
RuntimeWarning,
stacklevel=2,
)
return _app
@@ -32,8 +46,8 @@ def health():
@_app.get("/v1/config")
def config():
if _robot_json is None or not _robot_json.exists():
raise HTTPException(404, "Keine robot.json konfiguriert")
if _robot_json is None or not _robot_json.is_file():
raise HTTPException(404, "Keine robot.json konfiguriert (Datei fehlt oder ist ein Verzeichnis)")
data = json.loads(_robot_json.read_text(encoding="utf-8"))
return data.get("pose_estimation", {})
@@ -57,10 +71,10 @@ async def estimate(
if robot_json is not None:
rj_path = tmp_path / "robot.json"
rj_path.write_bytes(await robot_json.read())
elif _robot_json and _robot_json.exists():
elif _robot_json and _robot_json.is_file():
rj_path = _robot_json
else:
raise HTTPException(400, "Keine robot.json angegeben (weder Upload noch Server-Konfig)")
raise HTTPException(400, "Keine robot.json angegeben (weder Upload noch gültige Server-Konfig)")
for img in images:
(tmp_path / img.filename).write_bytes(await img.read())