Consume codegen endpoint registry (pilot: CexCandle)#113
Merged
Conversation
Adds datamaxi/_endpoints.py (generated by datamaxi-codegen from the backend OpenAPI spec) as the single source of truth for endpoint paths, methods, path/query split, required params, and defaults. - API.request_endpoint(op_id, **params): looks up the registry, fills defaults, enforces required params, interpolates path params, sends. - CexCandle refactored onto it (paths/param assembly removed); signatures, docstrings, semantic checks, and DataFrame conversion unchanged. - _endpoints.py is generated: excluded from black/flake8. Public interface unchanged; existing mocked tests pass unmodified.
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
First step toward single-sourcing endpoint metadata from
datamaxi-codegen. Adds the generated registry and a base-class helper, and pilots the pattern onCexCandle. No public interface change.datamaxi/_endpoints.py(generated) —ENDPOINTS[op_id]→ path, method, tag,requires_auth, group/subgroup, and per-param{required, in, type, default, enum, description}; regenerated from the backend OpenAPI spec viamake update-pythonin datamaxi-codegen.API.request_endpoint(op_id, **params)— looks up the registry as the source of truth for the URL path, HTTP method, path/query split, required params, and defaults; interpolatesin:pathparams; sends. Additive —query/send_requestuntouched.CexCandlerefactored onto it. Removed: hardcodedurl_pathstrings + manual param-dict assembly. Kept hand-written: signatures, doc-link docstrings, semantic checks (market ∈ [spot, futures], "no data found"), and DataFrame conversion._endpoints.pyis generated, so it's excluded fromblack(pyproject.tomlforce-exclude) andflake8(setup.cfgexclude). Emitter output only needs to be valid Python, not formatter-clean.Interface impact
None. Method signatures, defaults, return types, wire params, and error behavior are identical. The pre-existing
test_cex_candletests (which assert wire params + errors) pass unmodified — that's the proof the observable contract didn't move.request_endpointis a new additive method onAPI.Tests
black --check+flake8ondatamaxi/tests: clean (generated file correctly excluded).pytest: 113 passed, 127 skipped (skips are the live integration/smoke lanes needing an API key).Regenerating
_endpoints.pyis generated — edit endpoints in the backend spec, then from datamaxi-codegen runmake update-python DATAMAXI_PYTHON=/path/to/datamaxi-python(see codegen PR #19). Do not hand-edit.Follow-up (not in this PR)
required/enumvalidation too (would trim more hand code but changes some error messages).make check-pythondrift-guard into CI.