Skip to content

refactor: extract /api/v1/recipes into its own FastAPI router - #34

Merged
IAnMove merged 1 commit into
mainfrom
refactor/extract-recipes-router
Sep 1, 2026
Merged

refactor: extract /api/v1/recipes into its own FastAPI router#34
IAnMove merged 1 commit into
mainfrom
refactor/extract-recipes-router

Conversation

@IAnMove

@IAnMove IAnMove commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Alcance

Paso 2.piloto del plan canónico, sobre main 79dad74 (PRs #31 #32 #33 ya mezclados, CI de main verde).

  • Las 6 rutas /api/v1/recipes salen enteras de _launch_runtime.py a app/routers/recipes.py.
  • Se copian los handlers, se borran los originales y se monta create_recipes_router(...) en la misma posición ordinal (53–58).
  • Método, path, orden, status y JSON idénticos.
  • Dependencias explícitas: workspace_dir, nsfw_allowed, get_model_def, safe_join. No hay LaunchContext.
  • get_model_def viene del muro WanGP (services.generation).
  • Un commit revertible. Sin features nuevas.

Tabla estática: solo cambia sourceapp/routers/recipes.py. Ordinales, method y path intactos.

Tests locales

  • tests/test_recipes_router.py (ASGI): list NSFW, GET 404, thumbnail 404, save-from-output 400/mode, import 400, delete builtin 400
  • tests/test_architecture_contracts.py
  • tests/test_architecture_factory.py

Rollback

Un commit: git revert 8693e8d.

Confirmaciones

  • No se tocó vendor WanGP ni app/models/**.
  • No se extrajo otro dominio HTTP.
  • Hotspot _launch_runtime.py: este es el único PR de extracción sobre launch. No mezclar desde el agente.

Tras este PR el plan dice parar nuevas extracciones HTTP hasta asignación explícita.


Note

Low Risk
Mechanical route extraction with explicit dependency injection and new contract tests; no intended API or feature changes.

Overview
Moves all six Studio recipe HTTP endpoints out of _launch_runtime.py into app/routers/recipes.py, mounted via create_recipes_router(...) at the same route ordinals (53–58). Paths, methods, and handler behavior are intended to stay the same; the router takes injected callbacks (workspace_dir, nsfw_allowed, get_model_def, safe_join) so it does not import WanGP or the launch runtime. save-from-output now uses get_model_def from services.generation (passed in at mount time) instead of calling wgp.get_model_def directly.

tests/fixtures/route_table.json updates each recipe route’s source to the new module. tests/test_recipes_router.py adds ASGI contract tests for NSFW filtering, validation, save-from-output mode selection, import, and delete rules.

Reviewed by Cursor Bugbot for commit 8693e8d. Configure here.

Paso 2.piloto. Copy the six recipe handlers out of launch, delete the
originals, and mount create_recipes_router at the same ordinal. Method,
path, order, status and JSON stay the same. Workspace, NSFW policy and
get_model_def are injected; concat and WanGP stay behind existing ports.
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

PR Review — Loreframe Studio

Risk: low
Scope: 4 file(s); +303/-144

Automated review from scripts/analyze_pr.py. This is a heuristic pass (no LLM) so humans still own the merge decision.

Findings

  • No heuristic issues. Still run the CI checklist below.

Changed files

  • added: app/routers/recipes.py, tests/test_recipes_router.py
  • modified: app/_launch_runtime.py, tests/fixtures/route_table.json

CONTRIBUTING checklist

  • python scripts/verify_clean_repo.py
  • python -m compileall -q app/services app/launch.py scripts
  • cd ui && npm run build if the UI changed
  • No weights, CivitAI sidecars, or generated guides
  • Stays local-first (no required accounts / telemetry)

Posted by the repo PR review workflow. Re-runs on each push to the PR.

@IAnMove

IAnMove commented Sep 1, 2026

Copy link
Copy Markdown
Owner Author

cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8693e8d. Configure here.

@IAnMove
IAnMove merged commit dd110d1 into main Sep 1, 2026
5 checks passed
@IAnMove
IAnMove deleted the refactor/extract-recipes-router branch September 5, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant