Skip to content

feat: siren connection x402#6

Merged
TheGreatAlgo merged 6 commits into
mainfrom
x402
Mar 16, 2026
Merged

feat: siren connection x402#6
TheGreatAlgo merged 6 commits into
mainfrom
x402

Conversation

@TheGreatAlgo

@TheGreatAlgo TheGreatAlgo commented Feb 20, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Siren REST API support: fetch metric data, list regions, and configurable auth (API key or x402 wallet) exposed via client.
  • Bug Fixes

    • Improved lifecycle handling and error behavior when Siren is configured or absent; safer cleanup.
  • Errors

    • New Siren/x402-specific exception types for clearer failure reporting.
  • Documentation

    • README updates and examples showing Siren usage and x402 gateway flow.
  • Tests

    • New comprehensive tests covering Siren flows, auth paths, and response formats.
  • Chores

    • Version bump, added runtime dependencies, updated .gitignore.

@coderabbitai

coderabbitai Bot commented Feb 20, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: d3d6206d-1fb6-4f95-89e6-0cbac8ac4944

📥 Commits

Reviewing files that changed from the base of the PR and between 249188e and de3f702.

📒 Files selected for processing (4)
  • dclimate_client_py/__init__.py
  • dclimate_client_py/datasets.py
  • dclimate_client_py/stac_catalog.py
  • pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • pyproject.toml

📝 Walkthrough

Walkthrough

Adds a Siren REST API client and typed Siren surface (types, errors, exports), integrates optional Siren support into dClimateClient with API-key and x402 auth paths, and includes examples, tests, and dependency updates for httpx, x402, and python-dotenv.

Changes

Cohort / File(s) Summary
Siren types & exports
dclimate_client_py/siren/types.py, dclimate_client_py/siren/__init__.py, dclimate_client_py/__init__.py
Adds dataclasses/protocols and auth unions for Siren (SirenOptions, SirenAuth variants, SirenMetricQuery/MetricDataPoint, SirenRegion/Country, EvmSigner); re-exports them at package level and expands all.
Siren client implementation
dclimate_client_py/siren/siren_client.py
New async SirenClient with get_metric_data and list_regions, dual auth support (API-key and x402), dynamic x402 integration, HTTP handling, date/response parsing, and resource cleanup. Review auth branching, dynamic imports, and error mapping.
Core integration
dclimate_client_py/dclimate_client.py
Adds optional siren: SirenOptions ctor parameter, manages a private SirenClient lifecycle (init when provided, closed on aexit), and exposes async get_metric_data/list_regions. Raises if Siren usage is attempted but unconfigured.
Errors
dclimate_client_py/dclimate_zarr_errors.py
Introduces new exceptions: InvalidSelectionError, SirenApiError, X402PaymentError, and X402NotInstalledError.
Examples & gateway script
examples/siren_metric_data.py, examples/test_x402_siren_gateway.py
Adds an API-key usage example and an x402 gateway script demonstrating signer setup, region listing, and metric fetch; supports .env loading and env-var configuration.
Tests
tests/test_siren.py, plus adjustments in tests/*
Adds comprehensive tests for Siren API-key and x402 paths, response formats, env fallbacks, error cases, and dClimateClient integration; other tests updated for formatting and import changes.
Packaging / deps & misc
pyproject.toml, .gitignore
Bumps version, adds runtime deps httpx>=0.27.0, x402[evm,httpx]>=2.1.0, python-dotenv>=1.0.0; adds mnemonic.txt to .gitignore.
Dataset/catalog changes
dclimate_client_py/datasets.py, dclimate_client_py/stac_catalog.py, dclimate_client_py/client.py
Adds SpatialExtent/TemporalExtent types, extends dataset/catalog metadata and variant structures, enriches STAC extraction to populate per-variant extents and CIDs, and removes some IPFS/client import paths. Review type contract changes and stac parsing logic.
Concatenate & minor internals
dclimate_client_py/concatenate.py, dclimate_client_py/ipfs_retrieval.py, dclimate_client_py/stac_server.py, tests/*
Small bugfix/variable assignment change in concat, logging/formatting tweaks, added helper functions in stac_server/catalog, and general formatting adjustments across tests. Many changes are non-functional.

Sequence Diagrams

sequenceDiagram
    rect rgba(200,220,255,0.5)
    participant App as Application
    participant DC as dClimateClient
    participant SC as SirenClient
    participant API as Siren API
    end

    App->>DC: get_metric_data(query)
    activate DC
    DC->>SC: get_metric_data(query)
    activate SC
    SC->>SC: _format_date(...)
    alt API-key auth
        SC->>API: GET /metric?region_id=...&metric=... (Authorization: Bearer ...)
    else x402 auth
        SC->>SC: _get_x402_fetch()
        SC->>API: fetch /metric (x402-signed request)
    end
    API-->>SC: JSON response
    SC->>SC: _parse_metric_response(...)
    SC-->>DC: [SirenMetricDataPoint...]
    DC-->>App: [SirenMetricDataPoint...]
    deactivate SC
    deactivate DC
Loading
sequenceDiagram
    rect rgba(220,255,200,0.5)
    participant App as Application
    participant SC as SirenClient
    participant X402 as x402 Module
    participant Signer as EVM Signer
    participant API as Siren API
    end

    App->>SC: list_regions()
    activate SC
    alt API-key auth
        SC->>API: GET /regions (Authorization: Bearer ...)
    else x402 auth
        SC->>X402: import/setup fetch
        X402-->>SC: x402_fetch
        SC->>Signer: sign_typed_data(...)
        Signer-->>SC: signature
        SC->>API: fetch /regions (x402-signed)
    end
    API-->>SC: regions payload
    SC->>SC: _parse_regions_response(...)
    SC-->>App: [SirenRegion...]
    deactivate SC
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped to the Siren with keys so bright,

signed by a wallet or bearer of light,
regions and metrics in tidy array,
new types and errors to guide the way,
carrots and code — fetching data by night 🥕

📝 Coding Plan
  • Generate coding plan for human review comments

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

Tip

You can disable the changed files summary in the walkthrough.

Disable the reviews.changed_files_summary setting to disable the changed files summary in the walkthrough.

@TheGreatAlgo TheGreatAlgo merged commit 0c376db into main Mar 16, 2026
3 of 4 checks passed
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