fix: keep generated client compatible with FastAPI 0.141 and pin HpcRun wire format - #149
Merged
Merged
Conversation
…un wire format FastAPI >= 0.141 describes UploadFile fields with `contentMediaType: application/octet-stream` instead of `format: binary`. The pinned generator (openapi-python-client 0.29.1, the latest release) only recognises `format: binary` as a file upload; upstream support is still an open PR (openapi-generators/openapi-python-client#1418). Regenerating the client from the new spec would have turned every upload parameter into a plain `str` and broken pbest. - openapi_spec.py: normalise octet-stream string schemas back to `format: binary` after `get_openapi()`, so the generator keeps emitting `File` types. Remove once upstream ships contentMediaType support. - Regenerate the OpenAPI spec (it had been stale since the 0.4.0 models: container_def rename, ContainerizationEngine enum, ValidationError input/ctx) and the in-repo client. Upload fields are still typed `File`. - Add tests/api/test_hpc_run_serialization.py: inserts a simulator, simulation and HpcRun, fetches /results/simulation/status through the ASGI transport, and compares the JSON body to a checked-in fixture. FastAPI 0.130 moved response serialisation to pydantic-core; the same test passes against 0.116.2 and 0.141.1, so the payload pbest parses is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018TgVbCXXWAWhNjtKTzrxvN
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018TgVbCXXWAWhNjtKTzrxvN
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.
Summary
Follow-up to #127 (FastAPI 0.116 → 0.141).
Problem. FastAPI ≥ 0.141 emits
UploadFileschemas as{type: string, contentMediaType: application/octet-stream}instead of{type: string, format: binary}. The pinned client generator, openapi-python-client 0.29.1, is the latest release and only recognisesformat: binaryas a file upload (upstream fix is still open: openapi-generators/openapi-python-client#1418). Regeneratingcompose-api-clientfrom the new spec would have turned every upload parameter into a plainstr, breaking pbest'srun-simulationpath.Changes
compose_api/api/openapi_spec.py— post-process the spec afterget_openapi()and normalise octet-stream string schemas back toformat: binary. Ten lines, documented as temporary, delete once upstream shipscontentMediaTypesupport.compose_api/api/spec/openapi_3_1_0_generated.yamland the in-repo client. The spec had been stale since the 0.4.0 models (singularity_def→container_def, newContainerizationEngineenum,ValidationError.input/ctx). Upload fields in the regenerated client are still typedFile.tests/api/test_hpc_run_serialization.py+tests/fixtures/resources/hpc_run_response.json. Inserts a simulator, simulation andHpcRunvia the DB services, fetches/results/simulation/statusthroughASGITransport, and compares the JSON body (values and key order) to the fixture. This pins the wire format pbest parses across FastAPI 0.130's switch to pydantic-core serialisation.Not done here:
$LIB_DIR(the separate compose-api-client repo) was not regenerated; that is part of the four-step client release.Verification
make checkclean (pre-commit, mypy --strict, deptry)🤖 Generated with Claude Code
https://claude.ai/code/session_018TgVbCXXWAWhNjtKTzrxvN