Skip to content

API form-field contract + CI freshness check#5

Open
Alvin-Nahabwe wants to merge 1 commit into
feat/gradcamfrom
feat/api-contract
Open

API form-field contract + CI freshness check#5
Alvin-Nahabwe wants to merge 1 commit into
feat/gradcamfrom
feat/api-contract

Conversation

@Alvin-Nahabwe

Copy link
Copy Markdown
Collaborator

Stacked on #4 (gradcam → #3#2/#1). Diff collapses to just this change as the stack merges.

What

The API's half of contract enforcement between this service and the R client:

  • scripts/dump_contract.py — introspects the FastAPI OpenAPI schema (resolving $ref bodies) and emits dl_api_contract.json: for every form/multipart endpoint, the exact accepted field names.
  • dl_api_contract.json — committed contract (8 endpoints; e.g. /train/object-detection = 33 fields incl. weight_decay_hf/weight_decay_yolo; upload = data_file/data_name).
  • New CI job regenerates it and fails if the committed file is stale, so the contract can never silently fall behind the code.

Why

The R client drifting from this API is what broke the platform (wrong/renamed/dropped fields failing silently). The client repo vendors this file and validates its requests against it in CI (companion PR on no-code-app) — that check already caught and removed 23 dead fields the client was sending.

Flow when the API changes

  1. Change an endpoint's fields → contract CI here fails.
  2. python scripts/dump_contract.py > dl_api_contract.json, commit.
  3. Copy to no-code-app scripts/; its CI then reports exactly which client fields need updating.

🤖 Generated with Claude Code

scripts/dump_contract.py introspects the FastAPI OpenAPI schema and emits
dl_api_contract.json: for every form/multipart endpoint, the exact set of
accepted field names. This is the source of truth for the R client, whose
drift from this contract is what took the platform down (missing key,
data_zip vs data_file, weight_decay vs weight_decay_hf).

A CI job regenerates the contract and fails if the committed
dl_api_contract.json is stale, so it can never silently fall behind the
code. The no-code-app repo vendors this file and checks its requests
against it (companion PR there).

Verified: generator resolves the OpenAPI $ref bodies and emits correct
field sets (object-detection train = 33 fields incl. weight_decay_hf /
weight_decay_yolo; upload = data_file / data_name).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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