Files
python-sdk/Makefile
pptx704 03cd2227b5
All checks were successful
ci/woodpecker/push/unit Pipeline was successful
feat: prune SDK to API-key surface, add stats/usage/metrics/events
Strip session-only routes (auth, me, teams, hosts, channels, admin,
audit-logs) from api/openapi.yaml via new scripts/prune_openapi.py,
which is wired into `make generate` and `make prune-spec`. Spec drops
from 4787 to 1717 lines; regenerated _generated.py drops from 906 to
415 lines with all obsolete models removed.

Add SDK methods on CapsulesResource / AsyncCapsulesResource for the
apiKey-usable routes that were previously unwrapped:
  - capsules.stats(range=...)         -> CapsuleStats
  - capsules.usage(from_=..., to=...) -> UsageResponse (accepts date)
  - capsules.metrics(id, range=...)   -> CapsuleMetrics

Add EventsResource / AsyncEventsResource exposing
WrennClient.events.stream() over /v1/events/stream (SSE). Parser
handles `:keepalive` comments and multi-line `data:` frames.

Re-export new models (CapsuleStats, CapsuleMetrics, MetricPoint,
UsageResponse, SSEEvent, Resource, Actor) from wrenn.models.

Drop email-validator runtime dep (no EmailStr remains). Bump version
to 0.3.0 (pyproject + __version__). Add pyyaml to dev deps and
types-PyYAML to the pre-commit mypy hook for the prune script.

Normalize docstrings on new methods/classes to Google style with
Example:: blocks where useful. Regenerate docs/reference.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-23 01:28:54 +06:00

52 lines
1.4 KiB
Makefile

# Makefile
.PHONY: generate gen-docs lint test check test-integration test-code-runner prune-spec
# Variables
SPEC_URL = "https://raw.githubusercontent.com/wrennhq/wrenn/refs/heads/main/internal/api/openapi.yaml"
SPEC_PATH = "api/openapi.yaml"
generate:
@echo "Fetching latest OpenAPI spec from Git repo..."
mkdir -p api
curl -fsSL $(SPEC_URL) -o $(SPEC_PATH)
$(MAKE) prune-spec
uv run datamodel-codegen \
--input $(SPEC_PATH) \
--output src/wrenn/models/_generated.py \
--output-model-type pydantic_v2.BaseModel \
--snake-case-field \
--field-constraints \
--use-schema-description \
--target-python-version 3.13 \
--use-annotated \
--openapi-scopes schemas \
--formatters ruff-format ruff-check \
--input-file-type openapi
lint:
uv run ruff check src/
uv run ruff format --check src/
test:
uv run pytest tests/test_client.py tests/test_code_runner_unit.py -v
test-integration:
uv run pytest tests/ -v -m "integration or not integration" --ignore=tests/test_code_runner_e2e.py --ignore=tests/test_code_runner_unit.py
test-code-runner:
uv run pytest tests/test_code_runner_unit.py tests/test_code_runner_e2e.py -v -m "integration or not integration"
check: lint test
prune-spec:
@echo "Pruning spec down to the SDK's API-key surface..."
uv run python scripts/prune_openapi.py $(SPEC_PATH)
gen-docs:
mkdir -p docs
uv run pydoc-markdown > docs/reference.md