Skip to content

Commit b412c35

Browse files
feat: Rename evaluate_impl to _evaluate
1 parent 7176a40 commit b412c35

8 files changed

Lines changed: 12 additions & 16 deletions

File tree

src/sentry/preprod/size_analysis/grouptype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def _matches_query(self, data_packet: SizeAnalysisDataPacket) -> bool:
216216
)
217217
return False
218218

219-
def evaluate_impl(self, data_packet: SizeAnalysisDataPacket) -> GroupedDetectorEvaluationResult:
219+
def evaluate(self, data_packet: SizeAnalysisDataPacket) -> GroupedDetectorEvaluationResult:
220220
if not self._matches_query(data_packet):
221221
return GroupedDetectorEvaluationResult(result={}, tainted=False)
222222

src/sentry/processing_errors/grouptype.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def extract_value(
116116

117117
@override
118118
def extract_dedupe_value(self, data_packet: DataPacket[ProcessingErrorPacketValue]) -> int:
119-
# Not used — we override evaluate_impl and skip dedupe logic
119+
# Not used — we override evaluate and skip dedupe logic
120120
return 0
121121

122122
@override
@@ -167,7 +167,7 @@ def create_occurrence(
167167
return (occurrence, event_data)
168168

169169
@override
170-
def evaluate_impl(
170+
def evaluate(
171171
self, data_packet: DataPacket[ProcessingErrorPacketValue]
172172
) -> GroupedDetectorEvaluationResult:
173173
"""

src/sentry/workflow_engine/docs/adding-detectors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ flowchart TD
3030
State -->|No| Shared{Can use shared condition loading and metrics?}
3131
Shared -->|Yes| Base[Inherit BaseDetectorHandler]
3232
Shared -->|No| Interface[Implement DetectorHandler]
33-
Base --> Own[Implement full evaluate_impl orchestration]
33+
Base --> Own[Implement full evaluate orchestration]
3434
Interface --> OwnAll[Implement complete evaluate contract]
3535
```
3636

@@ -56,7 +56,7 @@ Uptime and metric issues are canonical examples.
5656

5757
[`BaseDetectorHandler`](../handlers/detector/base.py) provides condition-group loading
5858
and common evaluation metrics, but it does not provide a general stateless evaluation
59-
algorithm. A concrete subclass must implement `evaluate_impl`, `create_occurrence`,
59+
algorithm. A concrete subclass must implement `evaluate`, `create_occurrence`,
6060
`extract_value`, and `extract_dedupe_value`; custom orchestration can provide trivial
6161
implementations for hooks it does not use. The subclass owns its state and output
6262
semantics.

src/sentry/workflow_engine/docs/conditions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ A [`Detector`](../models/detector.py) represents configured detection. A runtime
252252
is selected through the detector type's [`DetectorSettings`](../types.py).
253253

254254
The common stateful path is
255-
[`StatefulDetectorHandler.evaluate_impl`](../handlers/detector/stateful.py):
255+
[`StatefulDetectorHandler.evaluate`](../handlers/detector/stateful.py):
256256

257257
1. Extract one packet-wide positive integer dedupe value.
258258
2. Extract one evaluation value or a mapping of `DetectorGroupKey` to value.

src/sentry/workflow_engine/handlers/detector/base.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def _evaluate(
147147
"result": "unknown",
148148
}
149149
try:
150-
value = self.evaluate_impl(data_packet)
150+
value = self.evaluate(data_packet)
151151
tags["result"] = "tainted" if value.tainted else "success"
152152
metrics.incr("workflow_engine_detector.evaluation", tags=tags, sample_rate=1.0)
153153
return value.result
@@ -157,9 +157,7 @@ def _evaluate(
157157
raise
158158

159159
@abc.abstractmethod
160-
def evaluate_impl(
161-
self, data_packet: DataPacket[DataPacketType]
162-
) -> GroupedDetectorEvaluationResult:
160+
def evaluate(self, data_packet: DataPacket[DataPacketType]) -> GroupedDetectorEvaluationResult:
163161
"""
164162
This method is used to evaluate the data packet's value against the conditions on the detector.
165163
"""

src/sentry/workflow_engine/handlers/detector/stateful.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,7 @@ def _build_workflow_engine_evidence_data(
410410

411411
return base
412412

413-
def evaluate_impl(
414-
self, data_packet: DataPacket[DataPacketType]
415-
) -> GroupedDetectorEvaluationResult:
413+
def evaluate(self, data_packet: DataPacket[DataPacketType]) -> GroupedDetectorEvaluationResult:
416414
dedupe_value = self.extract_dedupe_value(data_packet)
417415
group_data_values = self._extract_value_from_packet(data_packet)
418416
state = self.state_manager.get_state_data(list(group_data_values.keys()))

tests/sentry/workflow_engine/endpoints/test_organization_detector_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def setUp(self) -> None:
4343
self.registry_patcher.start()
4444

4545
class MockDetectorHandler(ConditionDetectorHandler[dict[Never, Never], bool]):
46-
def evaluate_impl(
46+
def evaluate(
4747
self, data_packet: DataPacket[dict[Never, Never]]
4848
) -> GroupedDetectorEvaluationResult:
4949
return GroupedDetectorEvaluationResult(

tests/sentry/workflow_engine/handlers/detector/test_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class NoHandlerGroupType(GroupType):
110110
category = GroupCategory.METRIC.value
111111

112112
class MockConditionDetectorHandler(ConditionDetectorHandler[dict[str, Any], int]):
113-
def evaluate_impl(
113+
def evaluate(
114114
self, data_packet: DataPacket[dict[str, Any]]
115115
) -> GroupedDetectorEvaluationResult:
116116
return GroupedDetectorEvaluationResult(
@@ -145,7 +145,7 @@ def extract_dedupe_value(self, data_packet: DataPacket[dict[str, Any]]) -> int:
145145
return data_packet.packet.get("dedupe", 0)
146146

147147
class MockConditionDetectorWithUpdateHandler(ConditionDetectorHandler[dict[str, Any], int]):
148-
def evaluate_impl(
148+
def evaluate(
149149
self, data_packet: DataPacket[dict[str, Any]]
150150
) -> GroupedDetectorEvaluationResult:
151151
status_change = StatusChangeMessage(

0 commit comments

Comments
 (0)