Skip to content

feat: well-production resource (#50) + remove committed credential from sdk_audit_test#52

Open
karlwaldman wants to merge 2 commits into
mainfrom
feat/well-production-resource
Open

feat: well-production resource (#50) + remove committed credential from sdk_audit_test#52
karlwaldman wants to merge 2 commits into
mainfrom
feat/well-production-resource

Conversation

@karlwaldman

Copy link
Copy Markdown
Member

Summary

  • Closes Add well-production resource and tests for /v1/well-production #50 — adds a well_production resource (sync client.well_production + async mirror) covering all seven /v1/well-production* endpoints: summary(), states(), state(), well(), top_producers(), cycle_time(), cycle_time_cohorts().
  • Security: removes a committed API-key credential from tests/sdk_audit_test.py (it was an os.getenv(...) or '<literal>' fallback in this public repo). The script now reads OILPRICEAPI_KEY / OILPRICEAPI_TEST_KEY from the environment only, skips cleanly (exit 0) when unset, and no longer prints key material. The exposed key must be rotated server-side — it remains in git history.

Implementation notes

  • Params verified against the live API and V1::WellProductionController in oilpriceapi-api: period (YYYY-MM), start_date/end_date, state_code/limit (server caps 100)/months, cycle-time filters (state, operator, formation, lat/lng/radius_miles, group_by).
  • API well numbers are validated/normalized client-side (14 digits, dashes stripped) via a shared normalize_api_number helper in resource_validators.py, so both sync and async raise a descriptive ValueError before any HTTP round-trip.
  • The entitlement gate is HTTP 403 ENTERPRISE_REQUIRED (drilling_intelligence feature), not 402 as the issue guessed — negative-path tests reflect the real behavior.
  • README/docs/CHANGELOG use beta caveats and do not claim complete US well-level production, per the issue's acceptance criteria.
  • oilpriceapi.resources.well_production is written mypy-strict-clean and pinned in the strict module list in pyproject.toml so it can't regress.

Test evidence (local, Python 3.14)

  • ruff check oilpriceapi/ — All checks passed
  • mypy oilpriceapi/ --ignore-missing-imports — Success: no issues found in 45 source files
  • pytest tests/ --ignore=tests/integration --ignore=tests/contract -m 'not slow'351 passed, 10 skipped (10 pre-existing optional-extra skips)
  • Live smoke against production (pytest tests/integration/test_live_well_production.py -m live) — 2 passed (envelope shapes verified with an entitled key; tests also accept the 403 gate so the free-tier CI key won't fail)
  • tests/sdk_audit_test.py with no key in env — prints skip message, exit 0

Known issue found during live verification (not SDK-side)

GET /v1/well-production/top-producers returns HTTP 500 in production (all other six endpoints return 200/expected errors). SDK method is included per the route contract; API-side fix tracked separately.

🤖 Generated with Claude Code

karlwaldman and others added 2 commits July 13, 2026 09:24
The standalone SDK audit script carried a literal API key as an
env-var fallback. It now reads OILPRICEAPI_KEY / OILPRICEAPI_TEST_KEY
from the environment only, skips cleanly (exit 0) when unset, and no
longer prints any key material. The exposed credential must be rotated
server-side.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tion (#50)

Adds client.well_production / AsyncOilPriceAPI.well_production covering:
- GET /v1/well-production (national summary + top states)
- GET /v1/well-production/states[/:code]
- GET /v1/well-production/wells/:api (14-digit validation client-side)
- GET /v1/well-production/top-producers
- GET /v1/well-production/cycle-time[/cohorts]

Params verified against the live API and the Rails controller
(V1::WellProductionController). Beta caveats documented (per-well data
limited to collected states; Drilling Intelligence plan gate is HTTP 403
ENTERPRISE_REQUIRED, not 402). Sync module is mypy strict-clean and
pinned in pyproject. Unit tests are fully mocked (no key needed); live
smokes tolerate the 403 gate for free-tier CI keys.

Closes #50

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@karlwaldman, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

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, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 23f7faa1-65b0-483d-81b6-b5c23bea0453

📥 Commits

Reviewing files that changed from the base of the PR and between 6cfa2d8 and 4552e5e.

📒 Files selected for processing (14)
  • CHANGELOG.md
  • README.md
  • docs/reference/resources.md
  • oilpriceapi/async_client.py
  • oilpriceapi/async_resources.py
  • oilpriceapi/client.py
  • oilpriceapi/resource_validators.py
  • oilpriceapi/resources/__init__.py
  • oilpriceapi/resources/well_production.py
  • pyproject.toml
  • tests/integration/test_live_well_production.py
  • tests/sdk_audit_test.py
  • tests/unit/test_async_well_production_resource.py
  • tests/unit/test_well_production_resource.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/well-production-resource

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

Add well-production resource and tests for /v1/well-production

1 participant