Skip to content

Consume codegen endpoint registry (pilot: CexCandle)#113

Merged
martinkersner merged 1 commit into
mainfrom
codegen-registry-pilot
Jul 1, 2026
Merged

Consume codegen endpoint registry (pilot: CexCandle)#113
martinkersner merged 1 commit into
mainfrom
codegen-registry-pilot

Conversation

@martinkersner

Copy link
Copy Markdown
Member

Summary

First step toward single-sourcing endpoint metadata from datamaxi-codegen. Adds the generated registry and a base-class helper, and pilots the pattern on CexCandle. 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 via make update-python in 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; interpolates in:path params; sends. Additive — query/send_request untouched.
  • CexCandle refactored onto it. Removed: hardcoded url_path strings + manual param-dict assembly. Kept hand-written: signatures, doc-link docstrings, semantic checks (market ∈ [spot, futures], "no data found"), and DataFrame conversion.
  • Lint: _endpoints.py is generated, so it's excluded from black (pyproject.toml force-exclude) and flake8 (setup.cfg exclude). 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_candle tests (which assert wire params + errors) pass unmodified — that's the proof the observable contract didn't move. request_endpoint is a new additive method on API.

Tests

  • black --check + flake8 on datamaxi/tests: clean (generated file correctly excluded).
  • pytest: 113 passed, 127 skipped (skips are the live integration/smoke lanes needing an API key).

Regenerating

_endpoints.py is generated — edit endpoints in the backend spec, then from datamaxi-codegen run make update-python DATAMAXI_PYTHON=/path/to/datamaxi-python (see codegen PR #19). Do not hand-edit.

Follow-up (not in this PR)

  • Roll the pattern out to the remaining client classes.
  • Decide whether the registry should own required/enum validation too (would trim more hand code but changes some error messages).
  • Wire codegen's make check-python drift-guard into CI.

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.
@martinkersner martinkersner merged commit 573d9a1 into main Jul 1, 2026
7 checks passed
@martinkersner martinkersner deleted the codegen-registry-pilot branch July 1, 2026 02:41
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