Commit 414ff42
Migrate Edge Configuration to SDK (#413)
Moves the edge endpoint config schema from `edge-endpoint` into the
Python SDK so users can programmatically build, validate, serialize, and
deserialize edge configurations.
## What's new
- New `groundlight.edge` config models ported from edge-endpoint:
- `EdgeEndpointConfig` (top-level config with `global_config`)
- `DetectorsConfig` (detector-scoped workflows)
- `InferenceConfig` (immutable/frozen per-detector inference behavior)
- `GlobalConfig`, `DetectorConfig` (supporting models)
- Preset constants aligned with edge-endpoint defaults:
- `DEFAULT`
- `EDGE_ANSWERS_WITH_ESCALATION`
- `NO_CLOUD`
- `DISABLED`
- Strict validation added with `extra="forbid"` across config models.
## Model design
- Shared detector/inference behavior is implemented once in internal
`ConfigBase`.
- `DetectorsConfig` and `EdgeEndpointConfig` both inherit from
`ConfigBase`.
- `EdgeEndpointConfig` is top-level and flat (`global_config`,
`edge_inference_configs`, `detectors`).
- `DetectorsConfig` remains available as a detector-only model.
## Validation behavior
- `disable_cloud_escalation=True` requires
`always_return_edge_prediction=True`.
- Duplicate detector IDs are rejected.
- Every detector's `edge_inference_config` must exist in
`edge_inference_configs`.
- Inference config dict-key/name mismatch is rejected.
- For payload dict input, `InferenceConfig.name` is hydrated from map
keys.
## Serialization / parsing API
- `EdgeEndpointConfig.from_yaml(filename=..., yaml_str=...)`
- Accepts exactly one input source.
- Supports file-path and YAML-string workflows explicitly.
- `EdgeEndpointConfig.to_payload()`
- Returns payload dict via `model_dump()`.
- `EdgeEndpointConfig.from_payload(payload)`
- Reconstructs from payload dict via `model_validate()`.
- `DetectorsConfig.to_payload()`
- Returns detector-scoped payload dict via `model_dump()`.
## Usage
```python
from groundlight.edge import (
DEFAULT,
EDGE_ANSWERS_WITH_ESCALATION,
GlobalConfig,
NO_CLOUD,
DetectorsConfig,
EdgeEndpointConfig,
)
# Full edge endpoint config
full_config = EdgeEndpointConfig(
global_config=GlobalConfig(refresh_rate=30.0, confident_audit_rate=0.0),
)
full_config.add_detector("det_abc123", NO_CLOUD)
full_config.add_detector("det_def456", DEFAULT)
payload = full_config.to_payload()
round_trip = EdgeEndpointConfig.from_payload(payload)
# Detector-only config
detectors_config = DetectorsConfig()
detectors_config.add_detector("det_abc123", NO_CLOUD)
detectors_config.add_detector("det_xyz789", EDGE_ANSWERS_WITH_ESCALATION)
detectors_payload = detectors_config.to_payload()
```
## Tests
Updated unit coverage in `test/unit/test_edge_config.py` includes:
- add-detector behavior and conflict handling
- constructor-time duplicate/cross-reference validation
- hydration of inference-config names from payload keys
- top-level payload acceptance and unknown-field rejection
- `from_yaml` (yaml string + filename + argument-validation cases)
- `to_payload` / `from_payload` round-trip
- direct literal-payload `from_payload` constructor coverage
- `InferenceConfig` validation constraints
## Dependencies
- `pyyaml` added as a runtime dependency in `python-sdk`
(`pyproject.toml`).
---------
Co-authored-by: Auto-format Bot <autoformatbot@groundlight.ai>
Co-authored-by: Tim Huff <thuff@axon.com>1 parent 4e9f371 commit 414ff42
File tree
4 files changed
+538
-1
lines changed- src/groundlight/edge
- test/unit
4 files changed
+538
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
0 commit comments