fix: futures slug normalization + live CI tests (v1.8.1)#35
Conversation
Futures endpoints are keyed by slug (ice-brent, ice-wti, ...), not raw
exchange contract code. The old docstrings advertised "CL.1" which would
hit /v1/futures/CL.1 and 404. Add contract-code -> slug normalization so
callers can pass either a slug or a friendly code, and fix the misleading
examples across the sync and async futures resources.
- New oilpriceapi/resources/_futures_slug.py: normalize_futures_slug()
maps BZ->ice-brent, CL->ice-wti, G/QS->ice-gasoil, NG->natural-gas,
TTF->ttf-gas, JKM->lng-jkm, EUA->eua-carbon, UKA->uk-carbon; passes
through canonical and continuous/{brent,wti} slugs; tolerates contract
suffixes (CL.1, CL1!, NG-2025-12). Verified against the Rails API
controller + routes.
- futures.continuous() now targets /v1/futures/continuous/{brent,wti}/historical.
- Add live integration test (tests/integration/test_live_futures.py, marked
live, excluded from the unit gate) using OILPRICEAPI_TEST_KEY; skips when
absent; spaced for the 1 req/sec limit.
- Add unit tests for slug normalization.
- Add live CI workflow (.github/workflows/live-tests.yml) gated on the
OILPRICEAPI_TEST_KEY secret so forks don't fail.
- Bump version 1.8.0 -> 1.8.1.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 38 minutes and 5 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…nd CI envs Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix: futures slug normalization + live CI tests (v1.8.1)
Futures endpoints are keyed by slug (ice-brent, ice-wti, ...), not raw
exchange contract code. The old docstrings advertised "CL.1" which would
hit /v1/futures/CL.1 and 404. Add contract-code -> slug normalization so
callers can pass either a slug or a friendly code, and fix the misleading
examples across the sync and async futures resources.
- New oilpriceapi/resources/_futures_slug.py: normalize_futures_slug()
maps BZ->ice-brent, CL->ice-wti, G/QS->ice-gasoil, NG->natural-gas,
TTF->ttf-gas, JKM->lng-jkm, EUA->eua-carbon, UKA->uk-carbon; passes
through canonical and continuous/{brent,wti} slugs; tolerates contract
suffixes (CL.1, CL1!, NG-2025-12). Verified against the Rails API
controller + routes.
- futures.continuous() now targets /v1/futures/continuous/{brent,wti}/historical.
- Add live integration test (tests/integration/test_live_futures.py, marked
live, excluded from the unit gate) using OILPRICEAPI_TEST_KEY; skips when
absent; spaced for the 1 req/sec limit.
- Add unit tests for slug normalization.
- Add live CI workflow (.github/workflows/live-tests.yml) gated on the
OILPRICEAPI_TEST_KEY secret so forks don't fail.
- Bump version 1.8.0 -> 1.8.1.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix: remove unused type-ignore (CI mypy under --ignore-missing-imports)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix: use unused-ignore so dateutil import passes mypy in both local and CI envs
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Hardens the futures path and turns on live CI testing.
Futures endpoints are keyed by slug (
ice-brent,ice-wti, ...), not by raw exchange contract code. The previous docstrings advertised"CL.1", which would build/v1/futures/CL.1and 404. This PR adds contract-code -> slug normalization (callers may pass either form), fixes the misleading examples, and wires up live CI.Code -> slug handling
New
oilpriceapi/resources/_futures_slug.pywithnormalize_futures_slug(), applied to both the sync (FuturesResource) and async (AsyncFuturesResource) resources:BZ/BRENTice-brentNG/NATGASnatural-gasCL/WTIice-wtiTTFttf-gasG/QS/GASOILice-gasoilJKM/LNGlng-jkmEUAeua-carbonUKAuk-carbonice-brent,ice-wti,ice-gasoil,natural-gas,ttf-gas,lng-jkm,eua-carbon,uk-carbon,continuous/brent,continuous/wti) pass through unchanged.CL.1,CL1!,NG-2025-12,BZ_2026_01.ValueErrorlisting valid slugs/codes.futures.continuous()now correctly targets/v1/futures/continuous/{brent,wti}/historical.app/controllers/v1/futures_controller.rb+config/routes.rbin the Rails API.Live CI
tests/integration/test_live_futures.py(markedlive, excluded from the default unit gate) usingOILPRICEAPI_TEST_KEY. Hits the real API:futures.latest("ice-brent"), the"BZ"code form (post-normalization), andfutures.curve(...). Asserts 200 + sane price. Skips when the key is absent (forks). Calls spaced for the 1 req/sec limit..github/workflows/live-tests.ymlruns the live suite withOILPRICEAPI_TEST_KEY: ${{ secrets.OILPRICEAPI_TEST_KEY }}, gated so forks/PRs without the secret don't fail.Version
Bumped
1.8.0->1.8.1(pyproject.toml+oilpriceapi/version.py).Gate results (local, venv)
mypy oilpriceapi/ --ignore-missing-imports-> Success: no issues found in 41 source filesruff check oilpriceapi/-> All checks passedpytest tests/ --ignore=tests/integration --ignore=tests/contract -m 'not slow' --cov=oilpriceapi-> 272 passed, 9 skipped; coverage 57.57% (>= 50% gate)OILPRICEAPI_TEST_KEY.🤖 Generated with Claude Code