Skip to content

Commit 0701e49

Browse files
committed
fix(aci): rename DataConditionHandler type and filter_group
1 parent c85bde8 commit 0701e49

23 files changed

+83
-77
lines changed

src/sentry/workflow_engine/handlers/condition/age_comparison_handler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
@condition_handler_registry.register(Condition.AGE_COMPARISON)
1313
class AgeComparisonConditionHandler(DataConditionHandler[WorkflowJob]):
14-
type = DataConditionHandler.Type.ACTION_FILTER
15-
filter_group = DataConditionHandler.FilterGroup.ISSUE_ATTRIBUTES
14+
group = DataConditionHandler.Group.ACTION_FILTER
15+
subgroup = DataConditionHandler.Subgroup.ISSUE_ATTRIBUTES
1616

1717
comparison_json_schema = {
1818
"type": "object",

src/sentry/workflow_engine/handlers/condition/anomaly_detection_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@condition_handler_registry.register(Condition.ANOMALY_DETECTION)
99
class AnomalyDetectionHandler(DataConditionHandler[WorkflowJob]):
10-
type = DataConditionHandler.Type.DETECTOR_TRIGGER
10+
group = DataConditionHandler.Group.DETECTOR_TRIGGER
1111
comparison_json_schema = {"type": "boolean"}
1212

1313
@staticmethod

src/sentry/workflow_engine/handlers/condition/assigned_to_handler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
@condition_handler_registry.register(Condition.ASSIGNED_TO)
1414
class AssignedToConditionHandler(DataConditionHandler[WorkflowJob]):
15-
type = DataConditionHandler.Type.ACTION_FILTER
16-
filter_group = DataConditionHandler.FilterGroup.ISSUE_ATTRIBUTES
15+
group = DataConditionHandler.Group.ACTION_FILTER
16+
subgroup = DataConditionHandler.Subgroup.ISSUE_ATTRIBUTES
1717

1818
comparison_json_schema = {
1919
"type": "object",

src/sentry/workflow_engine/handlers/condition/event_attribute_handler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
@condition_handler_registry.register(Condition.EVENT_ATTRIBUTE)
1515
class EventAttributeConditionHandler(DataConditionHandler[WorkflowJob]):
16-
type = DataConditionHandler.Type.ACTION_FILTER
17-
filter_group = DataConditionHandler.FilterGroup.EVENT_ATTRIBUTES
16+
group = DataConditionHandler.Group.ACTION_FILTER
17+
subgroup = DataConditionHandler.Subgroup.EVENT_ATTRIBUTES
1818

1919
comparison_json_schema = {
2020
"type": "object",

src/sentry/workflow_engine/handlers/condition/event_created_by_detector_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@condition_handler_registry.register(Condition.EVENT_CREATED_BY_DETECTOR)
99
class EventCreatedByDetectorConditionHandler(DataConditionHandler[WorkflowJob]):
10-
type = DataConditionHandler.Type.ACTION_FILTER
10+
group = DataConditionHandler.Group.ACTION_FILTER
1111

1212
@staticmethod
1313
def evaluate_value(job: WorkflowJob, comparison: Any) -> bool:

src/sentry/workflow_engine/handlers/condition/event_frequency_handlers.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
@condition_handler_registry.register(Condition.EVENT_FREQUENCY_COUNT)
1818
@condition_handler_registry.register(Condition.EVENT_UNIQUE_USER_FREQUENCY_COUNT)
1919
class EventFrequencyCountHandler(DataConditionHandler[list[int]]):
20-
type = DataConditionHandler.Type.ACTION_FILTER
21-
filter_group = DataConditionHandler.FilterGroup.FREQUENCY
20+
group = DataConditionHandler.Group.ACTION_FILTER
21+
subgroup = DataConditionHandler.Subgroup.FREQUENCY
2222

2323
comparison_json_schema = {
2424
"type": "object",
@@ -44,8 +44,8 @@ def evaluate_value(value: list[int], comparison: Any) -> DataConditionResult:
4444
@condition_handler_registry.register(Condition.EVENT_FREQUENCY_PERCENT)
4545
@condition_handler_registry.register(Condition.EVENT_UNIQUE_USER_FREQUENCY_PERCENT)
4646
class EventFrequencyPercentHandler(DataConditionHandler[list[int]]):
47-
type = DataConditionHandler.Type.ACTION_FILTER
48-
filter_group = DataConditionHandler.FilterGroup.FREQUENCY
47+
group = DataConditionHandler.Group.ACTION_FILTER
48+
subgroup = DataConditionHandler.Subgroup.FREQUENCY
4949

5050
comparison_json_schema = {
5151
"type": "object",
@@ -72,6 +72,8 @@ def evaluate_value(value: list[int], comparison: Any) -> DataConditionResult:
7272
# Percent sessions values must be between 0-100 (%)
7373
@condition_handler_registry.register(Condition.PERCENT_SESSIONS_COUNT)
7474
class PercentSessionsCountHandler(EventFrequencyCountHandler):
75+
group = DataConditionHandler.Group.ACTION_FILTER
76+
subgroup = DataConditionHandler.Subgroup.FREQUENCY
7577
comparison_json_schema = {
7678
"type": "object",
7779
"properties": {
@@ -90,6 +92,8 @@ class PercentSessionsCountHandler(EventFrequencyCountHandler):
9092
# This percent value can be > 100 (%)
9193
@condition_handler_registry.register(Condition.PERCENT_SESSIONS_PERCENT)
9294
class PercentSessionsPercentHandler(EventFrequencyPercentHandler):
95+
group = DataConditionHandler.Group.ACTION_FILTER
96+
subgroup = DataConditionHandler.Subgroup.FREQUENCY
9397
comparison_json_schema = {
9498
"type": "object",
9599
"properties": {

src/sentry/workflow_engine/handlers/condition/event_seen_count_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@condition_handler_registry.register(Condition.EVENT_SEEN_COUNT)
99
class EventSeenCountConditionHandler(DataConditionHandler[WorkflowJob]):
10-
type = DataConditionHandler.Type.ACTION_FILTER
10+
group = DataConditionHandler.Group.ACTION_FILTER
1111

1212
@staticmethod
1313
def evaluate_value(job: WorkflowJob, comparison: Any) -> bool:

src/sentry/workflow_engine/handlers/condition/existing_high_priority_issue_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
@condition_handler_registry.register(Condition.EXISTING_HIGH_PRIORITY_ISSUE)
1010
class ExistingHighPriorityIssueConditionHandler(DataConditionHandler[WorkflowJob]):
11-
type = DataConditionHandler.Type.WORKFLOW_TRIGGER
11+
group = DataConditionHandler.Group.WORKFLOW_TRIGGER
1212
comparison_json_schema = {"type": "boolean"}
1313

1414
@staticmethod

src/sentry/workflow_engine/handlers/condition/first_seen_event_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def is_new_event(job: WorkflowJob) -> bool:
1919

2020
@condition_handler_registry.register(Condition.FIRST_SEEN_EVENT)
2121
class FirstSeenEventConditionHandler(DataConditionHandler[WorkflowJob]):
22-
type = DataConditionHandler.Type.WORKFLOW_TRIGGER
22+
group = DataConditionHandler.Group.WORKFLOW_TRIGGER
2323
comparison_json_schema = {"type": "boolean"}
2424

2525
@staticmethod

src/sentry/workflow_engine/handlers/condition/issue_category_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
@condition_handler_registry.register(Condition.ISSUE_CATEGORY)
1010
class IssueCategoryConditionHandler(DataConditionHandler[WorkflowJob]):
11-
type = DataConditionHandler.Type.ACTION_FILTER
11+
group = DataConditionHandler.Group.ACTION_FILTER
1212

1313
comparison_json_schema = {
1414
"type": "object",

src/sentry/workflow_engine/handlers/condition/issue_occurrences_handler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
@condition_handler_registry.register(Condition.ISSUE_OCCURRENCES)
1010
class IssueOccurrencesConditionHandler(DataConditionHandler[WorkflowJob]):
11-
type = DataConditionHandler.Type.ACTION_FILTER
12-
filter_group = DataConditionHandler.FilterGroup.ISSUE_ATTRIBUTES
11+
group = DataConditionHandler.Group.ACTION_FILTER
12+
subgroup = DataConditionHandler.Subgroup.ISSUE_ATTRIBUTES
1313

1414
comparison_json_schema = {
1515
"type": "object",

src/sentry/workflow_engine/handlers/condition/issue_priority_equals.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
@condition_handler_registry.register(Condition.ISSUE_PRIORITY_EQUALS)
99
class IssuePriorityCondition(DataConditionHandler[WorkflowJob]):
10-
type = DataConditionHandler.Type.ACTION_FILTER
11-
filter_group = DataConditionHandler.FilterGroup.ISSUE_ATTRIBUTES
10+
group = DataConditionHandler.Group.ACTION_FILTER
11+
subgroup = DataConditionHandler.Subgroup.ISSUE_ATTRIBUTES
1212

1313
@staticmethod
1414
def evaluate_value(job: WorkflowJob, comparison: Any) -> bool:

src/sentry/workflow_engine/handlers/condition/issue_resolution_condition_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@condition_handler_registry.register(Condition.ISSUE_RESOLUTION_CHANGE)
99
class IssueResolutionConditionHandler(DataConditionHandler[WorkflowJob]):
10-
type = DataConditionHandler.Type.WORKFLOW_TRIGGER
10+
group = DataConditionHandler.Group.WORKFLOW_TRIGGER
1111

1212
@staticmethod
1313
def evaluate_value(job: WorkflowJob, comparison: Any) -> bool:

src/sentry/workflow_engine/handlers/condition/latest_adopted_release_handler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
@condition_handler_registry.register(Condition.LATEST_ADOPTED_RELEASE)
2020
class LatestAdoptedReleaseConditionHandler(DataConditionHandler[WorkflowJob]):
21-
type = DataConditionHandler.Type.ACTION_FILTER
22-
filter_group = DataConditionHandler.FilterGroup.EVENT_ATTRIBUTES
21+
group = DataConditionHandler.Group.ACTION_FILTER
22+
subgroup = DataConditionHandler.Subgroup.EVENT_ATTRIBUTES
2323

2424
comparison_json_schema = {
2525
"type": "object",

src/sentry/workflow_engine/handlers/condition/latest_release_handler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ def get_latest_release_for_env(
4141

4242
@condition_handler_registry.register(Condition.LATEST_RELEASE)
4343
class LatestReleaseConditionHandler(DataConditionHandler[WorkflowJob]):
44-
type = DataConditionHandler.Type.ACTION_FILTER
45-
filter_group = DataConditionHandler.FilterGroup.EVENT_ATTRIBUTES
44+
group = DataConditionHandler.Group.ACTION_FILTER
45+
subgroup = DataConditionHandler.Subgroup.EVENT_ATTRIBUTES
4646
comparison_json_schema = {"type": "boolean"}
4747

4848
@staticmethod

src/sentry/workflow_engine/handlers/condition/level_handler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
@condition_handler_registry.register(Condition.LEVEL)
1111
class LevelConditionHandler(DataConditionHandler[WorkflowJob]):
12-
type = DataConditionHandler.Type.ACTION_FILTER
13-
filter_group = DataConditionHandler.FilterGroup.EVENT_ATTRIBUTES
12+
group = DataConditionHandler.Group.ACTION_FILTER
13+
subgroup = DataConditionHandler.Subgroup.EVENT_ATTRIBUTES
1414

1515
comparison_json_schema = {
1616
"type": "object",

src/sentry/workflow_engine/handlers/condition/new_high_priority_issue_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
@condition_handler_registry.register(Condition.NEW_HIGH_PRIORITY_ISSUE)
1111
class NewHighPriorityIssueConditionHandler(DataConditionHandler[WorkflowJob]):
12-
type = DataConditionHandler.Type.WORKFLOW_TRIGGER
12+
group = DataConditionHandler.Group.WORKFLOW_TRIGGER
1313
comparison_json_schema = {"type": "boolean"}
1414

1515
@staticmethod

src/sentry/workflow_engine/handlers/condition/reappeared_event_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@condition_handler_registry.register(Condition.REAPPEARED_EVENT)
99
class ReappearedEventConditionHandler(DataConditionHandler[WorkflowJob]):
10-
type = DataConditionHandler.Type.WORKFLOW_TRIGGER
10+
group = DataConditionHandler.Group.WORKFLOW_TRIGGER
1111
comparison_json_schema = {"type": "boolean"}
1212

1313
@staticmethod

src/sentry/workflow_engine/handlers/condition/regression_event_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@condition_handler_registry.register(Condition.REGRESSION_EVENT)
99
class RegressionEventConditionHandler(DataConditionHandler[WorkflowJob]):
10-
type = DataConditionHandler.Type.WORKFLOW_TRIGGER
10+
group = DataConditionHandler.Group.WORKFLOW_TRIGGER
1111
comparison_json_schema = {"type": "boolean"}
1212

1313
@staticmethod

src/sentry/workflow_engine/handlers/condition/tagged_event_handler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
@condition_handler_registry.register(Condition.TAGGED_EVENT)
1111
class TaggedEventConditionHandler(DataConditionHandler[WorkflowJob]):
12-
type = DataConditionHandler.Type.ACTION_FILTER
13-
filter_group = DataConditionHandler.FilterGroup.EVENT_ATTRIBUTES
12+
group = DataConditionHandler.Group.ACTION_FILTER
13+
subgroup = DataConditionHandler.Subgroup.EVENT_ATTRIBUTES
1414

1515
comparison_json_schema = {
1616
"type": "object",

src/sentry/workflow_engine/processors/delayed_workflow.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ def fetch_group_to_event_data(
101101

102102

103103
def get_dcg_group_workflow_detector_data(
104-
workflow_event_dcg_data: dict[str, str]
105-
) -> tuple[DataConditionGroupGroups, dict[DataConditionHandler.Type, dict[int, int]]]:
104+
workflow_event_dcg_data: dict[str, str],
105+
) -> tuple[DataConditionGroupGroups, dict[DataConditionHandler.Group, dict[int, int]]]:
106106
"""
107107
Parse the data in the buffer hash, which is in the form of {workflow/detector_id}:{group_id}:{dcg_id, ..., dcg_id}:{dcg_type}
108108
"""
109109

110110
dcg_to_groups: DataConditionGroupGroups = defaultdict(set)
111-
trigger_type_to_dcg_model: dict[DataConditionHandler.Type, dict[int, int]] = defaultdict(dict)
111+
trigger_group_to_dcg_model: dict[DataConditionHandler.Group, dict[int, int]] = defaultdict(dict)
112112

113113
for workflow_group_dcg, _ in workflow_event_dcg_data.items():
114114
data = workflow_group_dcg.split(":")
115115
try:
116-
dcg_type = DataConditionHandler.Type(data[3])
116+
dcg_group = DataConditionHandler.Group(data[3])
117117
except ValueError:
118118
continue
119119

@@ -123,9 +123,9 @@ def get_dcg_group_workflow_detector_data(
123123
for dcg_id in dcg_ids:
124124
dcg_to_groups[dcg_id].add(group_id)
125125

126-
trigger_type_to_dcg_model[dcg_type][dcg_id] = int(data[0])
126+
trigger_group_to_dcg_model[dcg_group][dcg_id] = int(data[0])
127127

128-
return dcg_to_groups, trigger_type_to_dcg_model
128+
return dcg_to_groups, trigger_group_to_dcg_model
129129

130130

131131
def fetch_workflows_envs(
@@ -226,7 +226,7 @@ def get_condition_query_groups(
226226

227227

228228
def get_condition_group_results(
229-
queries_to_groups: dict[UniqueConditionQuery, set[int]]
229+
queries_to_groups: dict[UniqueConditionQuery, set[int]],
230230
) -> dict[UniqueConditionQuery, dict[int, int]]:
231231
condition_group_results = {}
232232
current_time = timezone.now()
@@ -386,7 +386,7 @@ def get_group_to_groupevent(
386386

387387
def fire_actions_for_groups(
388388
groups_to_fire: dict[int, set[DataConditionGroup]],
389-
trigger_type_to_dcg_model: dict[DataConditionHandler.Type, dict[int, int]],
389+
trigger_group_to_dcg_model: dict[DataConditionHandler.Group, dict[int, int]],
390390
group_to_groupevent: dict[Group, GroupEvent],
391391
) -> None:
392392
for group, group_event in group_to_groupevent.items():
@@ -396,9 +396,9 @@ def fire_actions_for_groups(
396396
workflow_triggers: set[DataConditionGroup] = set()
397397
action_filters: set[DataConditionGroup] = set()
398398
for dcg in groups_to_fire[group.id]:
399-
if dcg.id in trigger_type_to_dcg_model[DataConditionHandler.Type.WORKFLOW_TRIGGER]:
399+
if dcg.id in trigger_group_to_dcg_model[DataConditionHandler.Group.WORKFLOW_TRIGGER]:
400400
workflow_triggers.add(dcg)
401-
elif dcg.id in trigger_type_to_dcg_model[DataConditionHandler.Type.ACTION_FILTER]:
401+
elif dcg.id in trigger_group_to_dcg_model[DataConditionHandler.Group.ACTION_FILTER]:
402402
action_filters.add(dcg)
403403

404404
# process action filters
@@ -464,11 +464,11 @@ def process_delayed_workflows(
464464
workflow_event_dcg_data = fetch_group_to_event_data(project_id, Workflow, batch_key)
465465

466466
# Get mappings from DataConditionGroups to other info
467-
dcg_to_groups, trigger_type_to_dcg_model = get_dcg_group_workflow_detector_data(
467+
dcg_to_groups, trigger_group_to_dcg_model = get_dcg_group_workflow_detector_data(
468468
workflow_event_dcg_data
469469
)
470-
dcg_to_workflow = trigger_type_to_dcg_model[DataConditionHandler.Type.WORKFLOW_TRIGGER].copy()
471-
dcg_to_workflow.update(trigger_type_to_dcg_model[DataConditionHandler.Type.ACTION_FILTER])
470+
dcg_to_workflow = trigger_group_to_dcg_model[DataConditionHandler.Group.WORKFLOW_TRIGGER].copy()
471+
dcg_to_workflow.update(trigger_group_to_dcg_model[DataConditionHandler.Group.ACTION_FILTER])
472472

473473
_, workflows_to_envs = fetch_workflows_envs(list(dcg_to_workflow.values()))
474474
data_condition_groups = fetch_data_condition_groups(list(dcg_to_groups.keys()))
@@ -495,7 +495,7 @@ def process_delayed_workflows(
495495
dcg_group_to_event_data, list(groups_to_dcgs.keys()), event_ids, occurrence_ids, project_id
496496
)
497497

498-
fire_actions_for_groups(groups_to_dcgs, trigger_type_to_dcg_model, group_to_groupevent)
498+
fire_actions_for_groups(groups_to_dcgs, trigger_group_to_dcg_model, group_to_groupevent)
499499

500500
cleanup_redis_buffer(project_id, workflow_event_dcg_data, batch_key)
501501

src/sentry/workflow_engine/types.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,18 @@ def related_model(instance) -> list[ModelRelation]:
6464

6565

6666
class DataConditionHandler(Generic[T]):
67-
class Type(StrEnum):
67+
class Group(StrEnum):
6868
DETECTOR_TRIGGER = "detector_trigger"
6969
WORKFLOW_TRIGGER = "workflow_trigger"
7070
ACTION_FILTER = "action_filter"
7171

72-
class FilterGroup(StrEnum):
72+
class Subgroup(StrEnum):
7373
ISSUE_ATTRIBUTES = "issue_attributes"
7474
FREQUENCY = "frequency"
7575
EVENT_ATTRIBUTES = "event_attributes"
7676

77-
type: ClassVar[Type]
78-
filter_group: ClassVar[FilterGroup]
77+
group: ClassVar[Group]
78+
subgroup: ClassVar[Subgroup]
7979
comparison_json_schema: ClassVar[dict[str, Any]] = {}
8080

8181
@staticmethod

0 commit comments

Comments
 (0)