feat: add schema-compare command to test harness#2891
Conversation
2c85d07 to
a3e6902
Compare
Add a new `schema-compare` command that builds each model twice — once with COG_STATIC_SCHEMA=1 (Go tree-sitter) and once without (Python runtime) — then compares the resulting OpenAPI schemas for exact JSON equality. Differences are reported with a structured diff showing the exact JSON paths that diverge. Also add 7 local fixture models covering the full input type matrix: scalar types, optional types (PEP 604 + typing.Optional), list types, optional list types, constraints/choices, File/Path types, and structured BaseModel output.
a3e6902 to
1ce7b49
Compare
|
After reviewing the PR thoroughly, I found the code to be well-structured with proper error handling, good type annotations, and comprehensive documentation. The schema comparison logic is sound, resource cleanup is handled correctly with finally blocks, and the fixture models provide good coverage of input types. LGTM |
Add --cog-ref to build cog CLI + SDK wheel from any git ref (branch, tag, or commit SHA), enabling testing against main or feature branches without manual builds. When used, the SDK wheel is automatically built from the same ref and passed via COG_SDK_WHEEL. Also parallelize the static/runtime builds in schema-compare using ThreadPoolExecutor with distinct image tags, roughly halving wall-clock time per model. Extract _resolve_versions() helper to consolidate version resolution logic across all commands and produce clearer log output (no spurious PyPI lookups when --cog-ref provides a wheel).
|
After reviewing the PR thoroughly, I found the code to be well-structured with proper error handling, good type annotations, and comprehensive documentation. The schema comparison logic is sound, resource cleanup is handled correctly with finally blocks, and the fixture models provide good coverage of input types. LGTM |
The static schema generator was using TitleCaseSingle (which only uppercases the first character) instead of TitleCase (which splits on underscores) for the cancel endpoint path parameter. This produced "Prediction_id" instead of "Prediction Id", diverging from the Python runtime schema generator. Found by the test harness schema-compare command.
|
After reviewing the PR thoroughly, I found the code to be well-structured with proper error handling, good type annotations, and comprehensive documentation. The schema comparison logic is sound, resource cleanup is handled correctly with finally blocks, and the fixture models provide good coverage of input types. LGTM |
|
After thoroughly reviewing all the changes in PR #2891, I found the code to be well-structured and properly implemented: Summary: This PR adds a Key findings:
LGTM |
…icate/cog into mphelps/push-phase-progress * 'mphelps/push-phase-progress' of https://github.com/replicate/cog: (95 commits) feat: add metric name validation (#2911) Rename `cog run` to `cog exec` (#2916) chore(deps): bump github.com/google/go-containerregistry (#2884) fix: replace removed libgl1-mesa-glx in tensorflow integration test (#2914) ci: enforce stub freshness in CI, fix existing stub drift (#2912) feat: add schema-compare command to test harness (#2891) chore(deps): bump uuid from 1.22.0 to 1.23.0 in /crates (#2887) chore(deps): bump github.com/hashicorp/go-version from 1.7.0 to 1.9.0 (#2909) chore(deps): bump insta from 1.46.3 to 1.47.2 in /crates (#2908) fix: support list[X] | None inputs + integration tests for PEP 604 union File/Path coercion (#2882) ci: exclude Dependabot PRs from auto-code review (#2910) chore(deps): bump actions/checkout from 4 to 6 (#2904) chore(deps): bump github.com/testcontainers/testcontainers-go/modules/registry (#2886) fix: metrics bugs in coglet prediction server (#2896) Bump version to 0.17.2 (#2903) fix(coglet): propagate metric scope to async event loop thread (#2902) chore: remove unnecessary nolint directive in test (#2803) feat(coglet): add Sentry error reporting for infrastructure errors (#2865) fix: homebrew cask postflight xattr references wrong binary name (#2899) fix: include custom metrics in cog predict --json output (#2897) ...
Summary
Adds a
schema-comparecommand to the test harness (tools/test-harness/) that compares static (Go tree-sitter) vs runtime (Python) schema generation for regression detection.What's new
--cog-refflagBuild and test cog from any git ref (branch, tag, or commit SHA) without manual builds. Clones the repo, builds the CLI binary via
go buildand the SDK wheel viauv build, then uses both automatically:Resolution priority:
--cog-binary>--cog-ref>--cog-version> manifest default > latest stable--sdk-wheel>--cog-ref(auto-built) >--sdk-version> manifest default > latest stableParallel schema builds
The static and runtime builds now run concurrently using distinct Docker image tags (
:staticand:runtime), roughly halving wall-clock time per model.How it works
For each model,
schema-compare:COG_STATIC_SCHEMA=1and without — in parallelLocal fixture models
7 local fixture models (
fixtures/models/) covering the full input type matrix:scalar-typesoptional-typesX | NoneandOptional[X]for all typeslist-typeslist[X]andList[X]for str, int, Path, Fileoptional-list-typeslist[X] | NoneandOptional[List[X]]constraints-and-choicesfile-path-typescomplex-outputThese use
repo: localin the manifest and are loaded fromfixtures/models/without cloning.Example output