dc-mar-sdk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dc_mar_sdk-0.1.0/.gitignore +56 -0
- dc_mar_sdk-0.1.0/CHANGELOG.md +33 -0
- dc_mar_sdk-0.1.0/LICENSE +21 -0
- dc_mar_sdk-0.1.0/PKG-INFO +348 -0
- dc_mar_sdk-0.1.0/README.md +304 -0
- dc_mar_sdk-0.1.0/pyproject.toml +95 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/__init__.py +54 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/cache/__init__.py +19 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/cache/backends.py +492 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/cli/__init__.py +1 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/cli/main.py +1019 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/client/__init__.py +6 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/client/cache_policy.py +16 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/client/contracts.py +13 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/client/mar.py +729 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/dashboard/__init__.py +1 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/dashboard/app.py +147 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/dashboard/static/dashboard.css +95 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/dashboard/static/dashboard.js +95 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/dashboard/templates/index.html +72 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/models/__init__.py +77 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/models/core.py +313 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/operations.py +71 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/py.typed +0 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/scripts/__init__.py +1 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/scripts/geocode_quality_collect.py +333 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/scripts/release.py +155 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/settings.py +63 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/telemetry/__init__.py +11 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/telemetry/tracking.py +586 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/tools/__init__.py +0 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/tools/drift_detector.py +566 -0
- dc_mar_sdk-0.1.0/src/dc_mar_sdk/tools/swagger_manager.py +465 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
pip-wheel-metadata/
|
|
20
|
+
share/python-wheels/
|
|
21
|
+
*.egg-info/
|
|
22
|
+
.installed.cfg
|
|
23
|
+
*.egg
|
|
24
|
+
|
|
25
|
+
# Virtual environments
|
|
26
|
+
venv/
|
|
27
|
+
ENV/
|
|
28
|
+
env/
|
|
29
|
+
.venv
|
|
30
|
+
|
|
31
|
+
# IDE
|
|
32
|
+
.vscode/
|
|
33
|
+
.idea/
|
|
34
|
+
*.swp
|
|
35
|
+
*.swo
|
|
36
|
+
*~
|
|
37
|
+
.DS_Store
|
|
38
|
+
|
|
39
|
+
# Testing
|
|
40
|
+
.pytest_cache/
|
|
41
|
+
.coverage
|
|
42
|
+
htmlcov/
|
|
43
|
+
|
|
44
|
+
# Project specific
|
|
45
|
+
.uv/
|
|
46
|
+
uv.lock
|
|
47
|
+
*.db
|
|
48
|
+
.env
|
|
49
|
+
.env.local
|
|
50
|
+
.copilot_geocode_samples.json
|
|
51
|
+
artifacts/
|
|
52
|
+
|
|
53
|
+
# Build artifacts
|
|
54
|
+
dist/
|
|
55
|
+
build/
|
|
56
|
+
*.egg-info/
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on "Keep a Changelog" (https://keepachangelog.com/en/1.0.0/) and this project adheres to Semantic Versioning (https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
### Added
|
|
9
|
+
- Release documentation (RELEASE_POLICY.md) and changelog scaffold.
|
|
10
|
+
- Release quality gate runner: `dc-mar-sdk-release` (preferred public script name; legacy `dc-mar-sdk-release` still available) — runs lint + unit tests + optional smoke test.
|
|
11
|
+
- CLI command discovery/contract rejection and release-gate hygiene/check
|
|
12
|
+
sequencing regression coverage.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- Replaced Black with Ruff formatting, expanded Ruff lint coverage, and made
|
|
16
|
+
Ruff formatting plus linting mandatory in CI and the release quality gate.
|
|
17
|
+
- Added strict mypy enforcement to CI and the release quality gate, with typed
|
|
18
|
+
cache, telemetry, client, dashboard, CLI, Swagger, and drift boundaries.
|
|
19
|
+
- Hardened GitHub Actions with immutable action revisions, locked dependency
|
|
20
|
+
synchronization, and PyPI trusted publishing through short-lived OIDC tokens.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- Invalid cached autocomplete payloads are now evicted and refetched instead of
|
|
24
|
+
being returned to callers.
|
|
25
|
+
|
|
26
|
+
## [0.1.0] - 2026-07-18
|
|
27
|
+
### Added
|
|
28
|
+
- Initial public release and library scaffolding:
|
|
29
|
+
- Type-safe API client generated from the OpenAPI spec
|
|
30
|
+
- Pluggable caching backends (SQLite default, Redis, in-memory)
|
|
31
|
+
- Request telemetry and tracking
|
|
32
|
+
- Web dashboard (FastAPI) and CLI tool
|
|
33
|
+
- Release quality checks (ruff linting, pytest unit tests, optional local smoke test)
|
dc_mar_sdk-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mason Stoecker
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: dc-mar-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for DC DataGate Master Address Repository (MAR) API with caching and telemetry
|
|
5
|
+
Project-URL: Homepage, https://github.com/glass-water-star/dc-mar-sdk
|
|
6
|
+
Project-URL: Repository, https://github.com/glass-water-star/dc-mar-sdk
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/glass-water-star/dc-mar-sdk/issues
|
|
8
|
+
Author: Mason Stoecker
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: addresses,api,dc,geocoding,mar,sdk
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: fastapi>=0.104.0
|
|
21
|
+
Requires-Dist: httpx>=0.24.0
|
|
22
|
+
Requires-Dist: jinja2>=3.1.0
|
|
23
|
+
Requires-Dist: pydantic-settings>=2.0
|
|
24
|
+
Requires-Dist: pydantic>=2.0
|
|
25
|
+
Requires-Dist: rich>=13.0
|
|
26
|
+
Requires-Dist: sqlalchemy>=2.0
|
|
27
|
+
Requires-Dist: typer>=0.9.0
|
|
28
|
+
Requires-Dist: uvicorn>=0.24.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: mypy>=1.5.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff>=0.10.0; extra == 'dev'
|
|
35
|
+
Provides-Extra: ops
|
|
36
|
+
Requires-Dist: python-dotenv>=1.0; extra == 'ops'
|
|
37
|
+
Provides-Extra: redis
|
|
38
|
+
Requires-Dist: redis>=5.0.0; extra == 'redis'
|
|
39
|
+
Provides-Extra: test
|
|
40
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'test'
|
|
41
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'test'
|
|
42
|
+
Requires-Dist: pytest>=7.4.0; extra == 'test'
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# DC MAR SDK
|
|
46
|
+
|
|
47
|
+
[](https://github.com/glass-water-star/dc-mar-sdk/actions/workflows/lint.yml) [](https://github.com/glass-water-star/dc-mar-sdk/actions/workflows/tests.yml) [](https://github.com/glass-water-star/dc-mar-sdk/actions/workflows/smoke.yml)
|
|
48
|
+
|
|
49
|
+
A comprehensive Python SDK for the DC DataGate Master Address Repository (MAR) API with intelligent caching, telemetry tracking, and modern tooling.
|
|
50
|
+
|
|
51
|
+
The smoke badge points to a manual workflow_dispatch job and is not required to pass on pull requests by default.
|
|
52
|
+
|
|
53
|
+
## Features
|
|
54
|
+
|
|
55
|
+
- **Type-Safe API SDK** — Pydantic models generated from OpenAPI spec
|
|
56
|
+
- **Pluggable Caching** — SQLite (default), Redis, or in-memory backends with TTL and invalidation
|
|
57
|
+
|
|
58
|
+
Caching supports deterministic namespace/pattern invalidation across backends: Redis-style globbing is supported ("*" and "?" wildcards). SQLite and the in-memory backend perform safe, non-destructive pattern invalidation by matching keys (SQLite converts globs to SQL LIKE with proper escaping). Use CacheManager.invalidate_pattern(pattern) to remove keys matching a pattern. Note: pattern="*" will delete all entries (use clear() if you want an explicit full wipe).
|
|
59
|
+
|
|
60
|
+
Caching keys are namespaced deterministically by client scope to avoid cross-environment pollution: the namespace incorporates the effective API base URL (including API version/path) and a non-reversible SHA256 digest of the API key. Keys are prefixed with "dc-mar-sdk:v1" to keep cache scope deterministic by SDK version and API key scope.
|
|
61
|
+
- **Request Telemetry** — Track API usage, bytes transferred, cache hits/misses, endpoint popularity
|
|
62
|
+
- **Web Dashboard** — FastAPI-based interface for cache status, telemetry visualization, and queries
|
|
63
|
+
- **CLI Tool** — Command-line interface for querying, cache management, and data export
|
|
64
|
+
- **Modern Python Stack** — uv, pyproject.toml, Pydantic v2, FastAPI
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
> New here? See ONBOARDING.md for a concise API-key quick start, common mistakes, and copy-paste verification commands.
|
|
69
|
+
|
|
70
|
+
Note: The public import namespace is `dc_mar_sdk`.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
This project provides a CLI, a Python SDK, and a small FastAPI dashboard. The steps below get you up and running quickly; see Troubleshooting for common issues.
|
|
75
|
+
|
|
76
|
+
### Installation
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Install project dependencies & link package (recommended)
|
|
80
|
+
uv sync
|
|
81
|
+
|
|
82
|
+
# Or with pip for editable install
|
|
83
|
+
pip install -e .
|
|
84
|
+
|
|
85
|
+
# Or install the published SDK when released
|
|
86
|
+
pip install dc-mar-sdk
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Configure API key
|
|
90
|
+
|
|
91
|
+
Set your DC MAR API key in an environment variable used by the CLI and tests:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
export DC_MAR_API_KEY="<your_api_key>"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The CLI also accepts --api-key on the command line for one-off runs.
|
|
98
|
+
|
|
99
|
+
### CLI Usage (common commands)
|
|
100
|
+
|
|
101
|
+
- Drift check (full comparison). By default drift-check probes every documented
|
|
102
|
+
MAR operation and still respects robots.txt. Use `--safe-read-only` to limit
|
|
103
|
+
a run to GET operations:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Installed CLI:
|
|
107
|
+
dc-mar-cli drift-check --api-key "$DC_MAR_API_KEY"
|
|
108
|
+
# Local/dev (no install):
|
|
109
|
+
uv run dc-mar-cli drift-check --api-key "$DC_MAR_API_KEY"
|
|
110
|
+
# To limit the check to GET operations:
|
|
111
|
+
dc-mar-cli drift-check --api-key "$DC_MAR_API_KEY" --safe-read-only
|
|
112
|
+
# Local/dev equivalent:
|
|
113
|
+
uv run dc-mar-cli drift-check --api-key "$DC_MAR_API_KEY" --safe-read-only
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- Smoke drift (fast quick check):
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Installed CLI:
|
|
120
|
+
dc-mar-cli drift-smoke --api-key "$DC_MAR_API_KEY"
|
|
121
|
+
# Local/dev:
|
|
122
|
+
uv run dc-mar-cli drift-smoke --api-key "$DC_MAR_API_KEY"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
- Call any authoritative v2.2 operation. Use the exact Swagger path template
|
|
126
|
+
and provide each path value separately:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
uv run dc-mar-cli api-request \
|
|
130
|
+
--method GET \
|
|
131
|
+
--operation '/api/v2.2/units/{marid}' \
|
|
132
|
+
--path-parameter marid=1234567
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- Use validated, typed commands for the common MAR API families. These reject
|
|
136
|
+
malformed request data and fail if the live response violates its model:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
uv run dc-mar-cli locations address "1600 Pennsylvania" --zones Ward
|
|
140
|
+
uv run dc-mar-cli locations coordinates --longitude -77.0365 --latitude 38.8977
|
|
141
|
+
uv run dc-mar-cli locations batch --address-base64 "MTYwMCBQZW5uc3lsdmFuaWE="
|
|
142
|
+
uv run dc-mar-cli ssl lookup --square 0766 --lot 0038
|
|
143
|
+
uv run dc-mar-cli units lookup --marid 308596
|
|
144
|
+
uv run dc-mar-cli zone lookup "Ward 2"
|
|
145
|
+
uv run dc-mar-cli autocomplete-body "1600 Pennsylvania"
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- Target a specific swagger spec file:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Installed CLI:
|
|
152
|
+
dc-mar-cli drift-check --api-key "$DC_MAR_API_KEY" --swagger-file swagger/swagger.v7.json
|
|
153
|
+
# Local/dev:
|
|
154
|
+
uv run dc-mar-cli drift-check --api-key "$DC_MAR_API_KEY" --swagger-file swagger/swagger.v7.json
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Notes:
|
|
158
|
+
- Use --api-key to avoid relying on environment variables in CI.
|
|
159
|
+
- By default drift-check respects robots.txt. To override, use the --ignore-robots flag when you understand the consequences.
|
|
160
|
+
|
|
161
|
+
Caching notes:
|
|
162
|
+
- Client methods (autocomplete/search) now accept per-call cache overrides: use_cache (bool), refresh (bool), and ttl_seconds.
|
|
163
|
+
- CLI autocomplete supports --no-cache to bypass the cache for that invocation (does not clear global cache).
|
|
164
|
+
|
|
165
|
+
### Python Library (example)
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
import logging
|
|
169
|
+
import os
|
|
170
|
+
from dc_mar_sdk import MARClient
|
|
171
|
+
|
|
172
|
+
logging.basicConfig(level=logging.DEBUG) # helpful while developing
|
|
173
|
+
|
|
174
|
+
async with MARClient(api_key=os.environ.get("DC_MAR_API_KEY")) as client:
|
|
175
|
+
results = await client.autocomplete("1600 Pennsylvania")
|
|
176
|
+
print(results)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Web Dashboard
|
|
180
|
+
|
|
181
|
+
Run the dashboard locally and open http://localhost:8000. It intentionally binds
|
|
182
|
+
to loopback only and is not designed for external or multi-user deployment.
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
uv run uvicorn dc_mar_sdk.dashboard.app:app --reload
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Insights endpoints:
|
|
189
|
+
- `GET /api/insights/overview?hours=24`
|
|
190
|
+
- `GET /api/insights/timeseries?hours=24&bucket=hour`
|
|
191
|
+
- `GET /api/insights/endpoints?hours=24&limit=20`
|
|
192
|
+
- `GET /api/insights/anomalies?hours=24`
|
|
193
|
+
|
|
194
|
+
### Geocode quality sampling automation (robots-safe)
|
|
195
|
+
|
|
196
|
+
Collect a larger, intentionally messy address sample for quality heatmap analysis:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
uv run dc-mar-sdk-geocode-collect --max-samples 20
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Notes:
|
|
203
|
+
- Respects `robots.txt` and enforces crawl delay (currently 60s) between live calls.
|
|
204
|
+
- Uses `DC_MAR_API_KEY` or `--api-key`.
|
|
205
|
+
- Writes outputs to `artifacts/geocode-quality/`:
|
|
206
|
+
- `geocode_quality_samples.json`
|
|
207
|
+
- `geocode_quality_summary.json`
|
|
208
|
+
- `geocode_quality_points.geojson`
|
|
209
|
+
|
|
210
|
+
### Troubleshooting (quick matrix)
|
|
211
|
+
|
|
212
|
+
Below are common symptoms, likely causes, and practical fixes. If an error includes an HTTP status code or exception message, include that in any issue you file.
|
|
213
|
+
|
|
214
|
+
Symptom -> Likely cause -> Fix
|
|
215
|
+
|
|
216
|
+
- Authentication errors (401 / "invalid api key") -> Missing or wrong DC_MAR_API_KEY -> Verify env var, try --api-key, ensure no surrounding quotes, confirm key with provider. If running tests, set DC_RUN_SMOKE_TESTS=1 only when key is valid.
|
|
217
|
+
|
|
218
|
+
- Rate limit / 429 responses -> API enforced throttling -> Retry with backoff; reduce concurrency; cache responses; contact API owner for higher limits.
|
|
219
|
+
|
|
220
|
+
- Drift run shows "skipped: respects robots.txt" or many skipped endpoints -> robots.txt prevented crawling -> This is expected: drift-check honors robots.txt by default. Re-run with --ignore-robots if you need to test anyway.
|
|
221
|
+
|
|
222
|
+
- Drift output shows many validation errors or model mismatches -> OpenAPI spec changed or responses differ from spec -> Point drift-check to the correct --swagger-file; enable DEBUG logging to see which endpoint/spec entry failed; update generated models or the spec.
|
|
223
|
+
|
|
224
|
+
- Drift summary shows large "differences" but no request failures -> Legitimate API surface changes -> Inspect per-endpoint diffs in the drift output; run with --verbose or check drift output files to determine whether changes are additions, removals, or parameter type changes.
|
|
225
|
+
|
|
226
|
+
- CLI hangs or slow startup -> Missing/slow dependency (network, auth provider), or event loop blocked -> Try running the same command with DEBUG logs (ENV PYTHONASYNCIODEBUG=1 may help); check network connectivity.
|
|
227
|
+
|
|
228
|
+
- Web dashboard shows empty or stale cache -> Cache backend misconfigured (SQLite file path, Redis not running) -> Verify configuration in settings, ensure cache file is writable, or start Redis and configure accordingly. For SQLite, check file permissions and path.
|
|
229
|
+
|
|
230
|
+
- "Connection reset" or TLS errors -> Network or certificate issues -> Confirm system trust store; try curl to the API endpoint to see TLS errors; check proxies/firewalls.
|
|
231
|
+
|
|
232
|
+
- Tests requiring live API fail in CI -> API key not set or network blocked -> Use CI secrets to set DC_MAR_API_KEY, or skip smoke tests by not setting DC_RUN_SMOKE_TESTS.
|
|
233
|
+
|
|
234
|
+
If you need to capture more detail for debugging, enable DEBUG logs and include the command, flags, and a minimal excerpt of the output when filing issues.
|
|
235
|
+
|
|
236
|
+
## Architecture
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
src/dc_mar_sdk/
|
|
240
|
+
├── client/ — API client wrapper, cache integration
|
|
241
|
+
├── cache/ — Backend implementations (SQLite, Redis, in-memory)
|
|
242
|
+
├── telemetry/ — Usage tracking and analytics
|
|
243
|
+
├── models/ — Pydantic models (generated + enhanced)
|
|
244
|
+
├── cli/ — CLI tool (Typer)
|
|
245
|
+
└── dashboard/ — Web dashboard (FastAPI + templates/static)
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Development
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
# Run tests
|
|
252
|
+
uv run pytest
|
|
253
|
+
|
|
254
|
+
# Run optional live smoke test
|
|
255
|
+
DC_RUN_SMOKE_TESTS=1 DC_MAR_API_KEY=... uv run pytest tests/test_drift_smoke.py
|
|
256
|
+
|
|
257
|
+
# Type checking
|
|
258
|
+
uv run mypy src/
|
|
259
|
+
|
|
260
|
+
# Formatting & linting
|
|
261
|
+
uv run ruff format .
|
|
262
|
+
uv run ruff check .
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Release checks
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
# Lint + unit tests (packaged entry point)
|
|
269
|
+
uv run dc-mar-sdk-release
|
|
270
|
+
|
|
271
|
+
# If hygiene artifacts exist (__pycache__, *.pyc, lint/test caches), clean first
|
|
272
|
+
uv run dc-mar-sdk-release --fix-hygiene
|
|
273
|
+
|
|
274
|
+
# Lint + unit tests + local smoke test
|
|
275
|
+
uv run dc-mar-sdk-release --smoke --api-key "$DC_MAR_API_KEY"
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Release docs
|
|
279
|
+
|
|
280
|
+
- CHANGELOG: see CHANGELOG.md for a keep-a-changelog style history. Update the "Unreleased" section before tagging a release.
|
|
281
|
+
- Release policy & checklist: see RELEASE_POLICY.md for semantic versioning rules and a step-by-step release checklist (includes the `dc-mar-sdk-release` quality gates).
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
## CI cost controls
|
|
285
|
+
|
|
286
|
+
- Local-first: run the release and smoke checks locally. Use `uv run dc-mar-sdk-release` (add `--smoke --api-key` only when you want a live API check).
|
|
287
|
+
- When Actions run: workflows only trigger for pull requests targeting `main` and for pushes to `main`. Docs-only changes (`**/*.md`, `docs/**`) skip lint/tests to avoid unnecessary CI runs.
|
|
288
|
+
- Smoke tests: the smoke workflow is manual (workflow_dispatch) and supports an optional `allowed_actors` input to restrict who may run it.
|
|
289
|
+
|
|
290
|
+
Practical options to reduce CI spend further:
|
|
291
|
+
- Run tests/lint locally for fast feedback (zero CI cost).
|
|
292
|
+
- Move expensive checks to manual workflows or scheduled runs instead of per-PR.
|
|
293
|
+
- Use self-hosted runners for high-frequency, heavy jobs to lower GitHub bill (ops cost trades off).
|
|
294
|
+
- Batch or selective testing (only run tests for changed packages/files) to reduce runtime.
|
|
295
|
+
|
|
296
|
+
Tradeoffs: local-first and manual workflows reduce monetary cost but shift verification responsibility to contributors; self-hosted runners reduce GitHub charges but require maintenance.
|
|
297
|
+
|
|
298
|
+
## API Documentation
|
|
299
|
+
|
|
300
|
+
### Cache metrics (client-facing)
|
|
301
|
+
|
|
302
|
+
The MAR client exposes a normalized cache metrics API via MARClient.get_cache_stats(). This returns a stable dict suitable for downstream consumers with the following shape:
|
|
303
|
+
|
|
304
|
+
- backend: string (backend identifier)
|
|
305
|
+
- entries: int | null
|
|
306
|
+
- hits: int
|
|
307
|
+
- misses: int
|
|
308
|
+
- total_requests: int
|
|
309
|
+
- hit_rate: float (percentage 0-100, rounded to 2 decimals)
|
|
310
|
+
- size_bytes: int | null
|
|
311
|
+
- backend_details: dict (extra backend-specific fields)
|
|
312
|
+
|
|
313
|
+
Example usage:
|
|
314
|
+
|
|
315
|
+
```python
|
|
316
|
+
async with MARClient(api_key=...) as client:
|
|
317
|
+
stats = await client.get_cache_stats()
|
|
318
|
+
print(stats["hit_rate"], stats["entries"]) # 42.5, 123
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
This API is intentionally lightweight and does not require access to backend internals; the client normalizes backend-specific fields into the stable schema above.
|
|
322
|
+
|
|
323
|
+
## API Documentation
|
|
324
|
+
|
|
325
|
+
The DC MAR API provides geocoding and address matching services:
|
|
326
|
+
- **Autocomplete** — Get address suggestions from partial input
|
|
327
|
+
- **Search** — Advanced address search with filters
|
|
328
|
+
- **Reverse Geocoding** — Find addresses near coordinates
|
|
329
|
+
|
|
330
|
+
See `/swagger/swagger.json` for the full OpenAPI spec.
|
|
331
|
+
|
|
332
|
+
- **Model & API contract policy** — See CONTRACT_POLICY.md for transport envelope vs domain model rules, compatibility guidance, and examples.
|
|
333
|
+
|
|
334
|
+
## Roadmap
|
|
335
|
+
|
|
336
|
+
1. ✅ Phase 1: Infrastructure & Swagger fetch
|
|
337
|
+
2. ⬜ Phase 2: Generate client from Swagger, Pydantic models
|
|
338
|
+
3. ⬜ Phase 3: Cache & telemetry systems
|
|
339
|
+
4. ⬜ Phase 4: CLI and FastAPI dashboard
|
|
340
|
+
5. ⬜ Phase 5: Data exploration & business use cases
|
|
341
|
+
|
|
342
|
+
## Contributing
|
|
343
|
+
|
|
344
|
+
We welcome contributions! See CONTRIBUTING.md for setup, testing, linting, and PR expectations. Please follow the Code of Conduct in CODE_OF_CONDUCT.md. Use the issue and PR templates in .github/ to file bugs, feature requests, and pull requests.
|
|
345
|
+
|
|
346
|
+
## License
|
|
347
|
+
|
|
348
|
+
MIT
|