Break out vla-manager-api from dva-api - #74
Open
MYRhouma wants to merge 2 commits into
Open
Conversation
…reate VLA from templates endpoint
…ates before persisting
There was a problem hiding this comment.
Pull request overview
Adds a new vla-manager-api FastAPI service responsible for persisting Veracity Level Agreements (VLAs) and quality templates, including a “create VLA from templates” endpoint and a hand-written OpenAPI spec served via /swagger.
Changes:
- Introduces VLA CRUD endpoints plus
POST /vla/from-templatesthat renders stored templates and merges rendered quality into the persisted ODCS document. - Adds template CRUD + render endpoints (
/template*) backed by in-memory fakes and asyncpg PostgreSQL repos. - Adds initial unit tests for VLA CRUD and from-templates flows, plus Docker/uv packaging and an OpenAPI YAML spec.
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| vla-manager-api/uv.lock | Locks Python dependencies for the new service. |
| vla-manager-api/tests/test_vla_crud.py | Unit tests for VLA CRUD and /vla/from-templates. |
| vla-manager-api/tests/init.py | Marks test package. |
| vla-manager-api/src/vla_manager_api/template_routes.py | FastAPI routes for template CRUD + render. |
| vla-manager-api/src/vla_manager_api/routes.py | FastAPI routes for VLA CRUD + from-templates. |
| vla-manager-api/src/vla_manager_api/repo.py | Repo interfaces + Fake/Pg implementations; template rendering helper. |
| vla-manager-api/src/vla_manager_api/models.py | Pydantic DTOs for VLA + templates. |
| vla-manager-api/src/vla_manager_api/main.py | App factory + Swagger UI/spec serving; production repo builders. |
| vla-manager-api/src/vla_manager_api/dependencies.py | Lazy DI providers for VLA + template repos. |
| vla-manager-api/src/vla_manager_api/config.py | Environment-driven runtime configuration + logging setup. |
| vla-manager-api/src/vla_manager_api/auth.py | Bearer API-key guard for destructive endpoints. |
| vla-manager-api/src/vla_manager_api/init.py | Package metadata/docs. |
| vla-manager-api/README.md | Service overview and local run instructions. |
| vla-manager-api/pyproject.toml | Project metadata and dependencies. |
| vla-manager-api/Dockerfile | Container build/run setup including embedded OpenAPI YAML. |
| docs/spec/vla-manager-api.yaml | Hand-written OpenAPI 3.1 spec for the service. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+336
to
+338
| application/json: | ||
| schema: | ||
| $ref: '#/components/schemas/IDDTO' |
Comment on lines
+72
to
+74
| quality_templates: list[TemplateInstantiation] = Field( | ||
| alias="qualityTemplates", default_factory=list | ||
| ) |
Comment on lines
+106
to
+110
| @router.delete("/vla", status_code=status.HTTP_204_NO_CONTENT) | ||
| async def delete_all_vlas( | ||
| _: None = Depends(require_api_key), repo: VLARepo = Depends(get_repo) | ||
| ) -> None: | ||
| await repo.remove_all() |
| | `GET /vla` | VLA Manager UI, admin | List all VLAs | | ||
| | `GET /vla/{id}` | DVA API, UI | Retrieve a VLA by its UUID — used during VLA resolution in the synchronous attestation flow | | ||
| | `POST /vla` | VLA Manager UI | Create a VLA from a partial ODCS payload | | ||
| | `POST /vla/from-templates` | VLA Manager UI | *Reserved (501)* — implemented in a later refactor step | |
| ## Run locally (dev) | ||
|
|
||
| ```bash | ||
| cd data-veracity-main/vla-manager-api |
Comment on lines
+88
to
+92
| ) | ||
|
|
||
| pool = await asyncpg.create_pool(dsn=cfg.postgres_dsn, min_size=1, max_size=4) | ||
| repo = PgTemplateRepo(pool) | ||
| await repo._ensure_schema() |
Comment on lines
+62
to
+66
| async def add(self, vla: dict[str, Any]) -> Optional[UUID]: | ||
| id = uuid4() | ||
| # Strip any caller-supplied "id" before persisting — persistence | ||
| # owns the id, not the caller. | ||
| vla = {k: v for k, v in vla.items() if k != "id"} |
Comment on lines
+39
to
+41
| @router.get("/template", response_model=list[Template]) | ||
| async def list_templates(repo: TemplateRepo = Depends(get_template_repo)) -> list[dict[str, Any]]: | ||
| return await repo.all() |
Comment on lines
+47
to
+50
| vla = await repo.by_id(id) | ||
| if vla is None: | ||
| raise HTTPException(status.HTTP_404_NOT_FOUND) | ||
| return vla |
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.
Adds the VLA Manager FastAPI service that owns VLA and quality-template persistence, replacing the removed dva-api VLA/template routes.
POST /vla,GET /vla[/{id}],DELETE /vla/{id}POST /vla/from-templatesrenders Handlebars templates against the supplied model and appends the rendered quality implementations to the persisted ODCS documentFakeVLARepo/FakeTemplateRepouse caller-supplied ids to keep tests deterministicVLANewFromTemplates.model_dumpis JSON-serialized and thequalityTemplatesfield is stripped before persistence so UUIDs in nested DTOs do not breakjson.dumpspytest tests/-> 10 passed)Depends on: none
@bzp99