Skip to content

Commit ae984c7

Browse files
committed
Fixing evaluation corner case and label
1 parent 9e1a81b commit ae984c7

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

splitio/clients.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@ def _get_treatment_for_split(self, split, matching_key, bucketing_key, attribute
178178
roll_out = False
179179
for condition in split.conditions:
180180
if (not roll_out and
181-
condition.condition_type == ConditionType.ROLLOUT):
181+
condition.condition_type == ConditionType.ROLLOUT):
182182
if split.traffic_allocation < 100:
183183
bucket = self.get_splitter().get_bucket(
184184
bucketing_key,
185185
split.traffic_allocation_seed,
186186
split.algo
187187
)
188188
if bucket >= split.traffic_allocation:
189-
return split.default_treatment, condition.label
189+
return split.default_treatment, Label.NOT_IN_SPLIT
190190
roll_out = True
191191

192192
if condition.matcher.match(matching_key, attributes=attributes):

splitio/impressions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ class Label(object):
5656
#Label: split not found
5757
SPLIT_NOT_FOUND = 'rules not found'
5858

59+
#Condition: Traffic allocation failed
60+
#Treatment: Default Treatment
61+
#Label: not in split
62+
NOT_IN_SPLIT = 'not in split'
63+
5964
# Condition: There was an exception
6065
# Treatment: control
6166
# Label: exception

splitio/splits.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ def __init__(self, name, seed, killed, default_treatment, traffic_type_name,
7373
self._status = status
7474
self._change_number = change_number
7575
self._conditions = conditions if conditions is not None else []
76-
self._traffic_allocation = traffic_allocation if traffic_allocation else 100
76+
77+
if traffic_allocation >= 0 and traffic_allocation <= 100:
78+
self._traffic_allocation = traffic_allocation
79+
else:
80+
self._traffic_allocation = 100
81+
7782
self._traffic_allocation_seed = traffic_allocation_seed
7883
try:
7984
self._algo = HashAlgorithm(algo)

0 commit comments

Comments
 (0)