Skip to content

Commit fcdad1f

Browse files
update: enhance bucketing logic to support CMAB traffic allocations
1 parent 0bc4fbd commit fcdad1f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

optimizely/bucketer.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,16 @@ def bucket_to_entity_id(
179179
project_config.logger.info(message)
180180
decide_reasons.append(message)
181181

182+
traffic_allocations: list[TrafficAllocation] = experiment.trafficAllocation
183+
if experiment.cmab:
184+
traffic_allocations = [
185+
{
186+
"entityId": "$",
187+
"endOfRange": experiment.cmab['trafficAllocation']
188+
}
189+
]
182190
# Bucket user if not in white-list and in group (if any)
183191
variation_id = self.find_bucket(project_config, bucketing_id,
184-
experiment.id, experiment.trafficAllocation)
192+
experiment.id, traffic_allocations)
185193

186194
return variation_id, decide_reasons

optimizely/decision_service.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ def get_variation(
490490
# If so, handle CMAB-specific traffic allocation and decision logic.
491491
# Otherwise, proceed with standard bucketing logic for non-CMAB experiments.
492492
if experiment.cmab:
493-
experiment.cmab
494493
cmab_decision_result = self._get_decision_for_cmab_experiment(project_config,
495494
experiment,
496495
user_context,

0 commit comments

Comments
 (0)