feat(backend): thin FastAPI wrapper around the ingen CLI - #75
Open
maan-iitd2 wants to merge 1 commit into
Open
Conversation
Adds backend/app/, a local-dev-only HTTP service that shells out to `python -m ingen` and returns structured results — no business logic of its own, just routing, temp-YAML execution, run-history persistence, and a few read helpers the frontend needs (source column introspection, sample file upload/preview). - main.py: routes only, delegates to the modules below. - runner.py: writes posted YAML to a temp file, runs the CLI as a subprocess, parses its log output into a structured RunRecord (stages, real log levels, timing). - store.py: persists RunRecords to INGEN_RUNS_DIR for history/lookup. - schema_validate.py / validation.py: validate a config (and surface a run's validation results) without executing it. - files.py: sample-data upload with size/type caps, reading only headers for column preview (not the whole file). - columns.py: derive the column list a configured source would produce, for the frontend's editor. Deliberately excluded from this PR: the inChat assistant (backend/app/chat.py), which pulls in torch/transformers and is a separable concern — follow-up PR. ## Testing - `pytest backend/tests/` — 42 passed. - Verified backend.app.main imports cleanly and registers all 9 routes with torch/transformers/accelerate/safetensors/tokenizers/ huggingface_hub deliberately blocked at import time (sys.meta_path), proving this PR has no import-time dependency on the inChat stack. - End-to-end: booted `uvicorn backend.app.main:app`, hit /api/health, POSTed a real config to /api/configs/validate, and POSTed a real XML config to /api/runs — the CLI subprocess ran the full read → pre_process → format → validate → write pipeline and the endpoint returned a RunRecord with status "success". - Updated backend/README.md, which had drifted from main.py (missing the files/columns endpoints, wrong default CORS ports) — corrected to describe exactly what this PR ships. Signed-off-by: maan-iitd2 <maan.iitd.ac.in@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
backend/app/— a thin, local-dev-only FastAPI service that runs the InGen CLI and returns structured results. It contains no business logic: it shells out topython -m ingen, parses the CLI's output, and hands JSON back to a frontend (the InGen Studio SPA, not part of this PR).main.pyrunner.pyRunRecord(per-stage status, timing, log level)store.pyRunRecords toINGEN_RUNS_DIRfor history/lookupschema_validate.py/validation.pyfiles.pycolumns.pyDeliberately excluded from this PR: the inChat assistant (
backend/app/chat.py), which pulls intorch/transformers/HuggingFace and is a separable concern with its own dependency weight — follow-up PR.main.pyin this PR has no chat import, no/api/chat*routes.Trust boundary
This wrapper executes whatever config is posted (file reads, SQL, API calls — that's InGen's nature). It's intended for local/trusted development only — no auth, sandboxing, or network egress controls, by design.
Testing
pytest backend/tests/— 42 passed.backend.app.mainimports cleanly and registers all 9 routes withtorch/transformers/accelerate/safetensors/tokenizers/huggingface_hubdeliberately blocked at import time (viasys.meta_path), proving this PR carries no import-time dependency on the inChat stack even though those packages happened to be present in the test environment.uvicorn backend.app.main:app --port 8123, then:GET /api/health→{"status": "ok"}POST /api/configs/validatewith a real config → validated correctlyPOST /api/runswith a real XML-source config → the CLI subprocess ran the fullread → pre_process → format → validate → writepipeline and the endpoint returned aRunRecordwith"status": "success"and per-stage logs.backend/README.mdhad drifted frommain.py(missing the files/columns endpoints, wrong default CORS ports/origin). Corrected it to describe exactly what this PR ships.🤖 Generated with Claude Code