You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor: Align get_variations_for_feature_list with Swift SDK
This commit refactors get_variations_for_feature_list to match Swift's
getVariationForFeatureList architecture, simplifying the code and
ensuring consistent decision flow.
## Problem
Python's get_variations_for_feature_list had duplicate logic:
- Manually handled experiments (forced decisions, variations)
- Manually handled rollouts
- Did NOT call get_decision_for_flag
- Did NOT evaluate holdouts at all
- ~120 lines of complex, duplicated code
## Solution
Aligned with Swift SDK approach:
1. Create user profile tracker ONCE
2. Load profile ONCE
3. Loop through features, calling get_decision_for_flag for each
4. Save profile ONCE
5. Return all decisions
## Changes
optimizely/decision_service.py:
### get_variations_for_feature_list:
- Simplified from ~120 lines to ~60 lines
- Removed duplicate experiment/rollout handling
- Now delegates to get_decision_for_flag for each feature
- User profile tracker created/saved once (efficient)
### get_decision_for_flag:
- Fixed circular dependency
- Now handles experiments and rollouts directly
- Does NOT call get_variations_for_feature_list
- Flow: Holdouts → Experiments → Rollouts
## Benefits
✅ Code simplification: ~50% reduction in lines
✅ Eliminates duplicate logic for experiments/rollouts
✅ Ensures holdouts always evaluated (via get_decision_for_flag)
✅ User profile efficiency (load once, save once)
✅ Matches Swift SDK architecture exactly
✅ No circular dependencies
✅ Easier to maintain
## Swift Alignment
Swift's getVariationForFeatureList:
- Creates tracker once
- Loops, calling getDecisionForFlag for each
- Saves once
Python's get_variations_for_feature_list (now):
- Creates tracker once
- Loops, calling get_decision_for_flag for each
- Saves once
Perfect alignment! ✓
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
0 commit comments