Skip to content

Commit d0608a1

Browse files
committed
responding to PR feedback
1 parent bf0c284 commit d0608a1

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

src/groundlight/edge/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from .config import (
2-
ConfigBase,
32
DEFAULT,
43
DISABLED,
54
EDGE_ANSWERS_WITH_ESCALATION,
@@ -16,7 +15,6 @@
1615
"DISABLED",
1716
"EDGE_ANSWERS_WITH_ESCALATION",
1817
"NO_CLOUD",
19-
"ConfigBase",
2018
"DetectorsConfig",
2119
"DetectorConfig",
2220
"EdgeEndpointConfig",

src/groundlight/edge/config.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,8 @@ def add_detector(self, detector: Union[str, Detector], edge_inference_config: In
156156
self.detectors.append(DetectorConfig(detector_id=detector_id, edge_inference_config=edge_inference_config.name))
157157

158158
def to_payload(self) -> dict[str, Any]:
159-
"""Return detector payload used by edge-endpoint config HTTP APIs."""
160-
return {
161-
"edge_inference_configs": {
162-
name: config.model_dump() for name, config in self.edge_inference_configs.items()
163-
},
164-
"detectors": [detector.model_dump() for detector in self.detectors],
165-
}
159+
"""Return this config as a payload dictionary."""
160+
return self.model_dump()
166161

167162

168163
class DetectorsConfig(ConfigBase):
@@ -199,16 +194,6 @@ def from_yaml(
199194
parsed = yaml.safe_load(yaml_text) or {}
200195
return cls.model_validate(parsed)
201196

202-
def to_payload(self) -> dict[str, Any]:
203-
"""Return the full edge-endpoint payload shape."""
204-
return {
205-
"global_config": self.global_config.model_dump(),
206-
"edge_inference_configs": {
207-
name: config.model_dump() for name, config in self.edge_inference_configs.items()
208-
},
209-
"detectors": [detector.model_dump() for detector in self.detectors],
210-
}
211-
212197
@classmethod
213198
def from_payload(cls, payload: dict[str, Any]) -> "EdgeEndpointConfig":
214199
"""Construct an EdgeEndpointConfig from a payload dictionary."""

test/unit/test_edge_config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,21 @@ def test_edge_endpoint_config_from_payload_round_trip():
269269
assert reconstructed == config
270270

271271

272+
def test_edge_endpoint_config_from_payload_accepts_literal_payload():
273+
"""Constructs EdgeEndpointConfig from a literal payload dictionary."""
274+
payload = {
275+
"global_config": {"refresh_rate": 15.0},
276+
"edge_inference_configs": {"default": {"enabled": True}},
277+
"detectors": [{"detector_id": "det_1", "edge_inference_config": "default"}],
278+
}
279+
280+
config = EdgeEndpointConfig.from_payload(payload)
281+
282+
assert config.global_config.refresh_rate == 15.0
283+
assert config.edge_inference_configs["default"].name == "default"
284+
assert [detector.detector_id for detector in config.detectors] == ["det_1"]
285+
286+
272287
def test_inference_config_validation_errors():
273288
"""Raises on invalid inference config flag combinations and values."""
274289
with pytest.raises(ValueError, match="disable_cloud_escalation"):

0 commit comments

Comments
 (0)