@@ -293,6 +293,9 @@ def _get_feature_variable_for_type(
293
293
)
294
294
295
295
if decision .source == enums .DecisionSources .FEATURE_TEST :
296
+
297
+ print ('DECISION.EXPERIMENT - ' , decision .experiment )
298
+
296
299
source_info = {
297
300
'experiment_key' : decision .experiment .key ,
298
301
'variation_key' : decision .variation .key ,
@@ -444,20 +447,14 @@ def activate(self, experiment_key, user_id, attributes=None):
444
447
self .logger .error (enums .Errors .INVALID_PROJECT_CONFIG .format ('activate' ))
445
448
return None
446
449
447
- variation = self .get_variation (experiment_key , user_id , attributes )
448
-
449
- if not variation :
450
- self .logger .info ('Not activating user "%s".' % user_id )
451
- return None
452
-
453
- variation_key , reasons = variation
450
+ variation_key = self .get_variation (experiment_key , user_id , attributes )
454
451
455
452
if not variation_key :
456
453
self .logger .info ('Not activating user "%s".' % user_id )
457
454
return None
458
455
459
456
experiment = project_config .get_experiment_from_key (experiment_key )
460
- variation = project_config .get_variation_from_key (experiment_key , variation_key . key )
457
+ variation = project_config .get_variation_from_key (experiment_key , variation_key )
461
458
462
459
# Create and dispatch impression event
463
460
self .logger .info ('Activating user "%s" in experiment "%s".' % (user_id , experiment .key ))
@@ -555,7 +552,10 @@ def get_variation(self, experiment_key, user_id, attributes=None):
555
552
return None
556
553
557
554
user_context = self .create_user_context (user_id , attributes )
558
- variation_key = self .decision_service .get_variation (project_config , experiment , user_context )
555
+
556
+ variation , _ = self .decision_service .get_variation (project_config , experiment , user_context )
557
+ if variation :
558
+ variation_key = variation .key
559
559
560
560
if project_config .is_feature_experiment (experiment .id ):
561
561
decision_notification_type = enums .DecisionNotificationTypes .FEATURE_TEST
@@ -841,7 +841,7 @@ def get_feature_variable_json(self, feature_key, variable_key, user_id, attribut
841
841
project_config , feature_key , variable_key , variable_type , user_id , attributes ,
842
842
)
843
843
844
- def get_all_feature_variables (self , feature_key , user_id , attributes ):
844
+ def get_all_feature_variables (self , feature_key , user_id , attributes = None ):
845
845
""" Returns dictionary of all variables and their corresponding values in the context of a feature.
846
846
847
847
Args:
@@ -1047,10 +1047,10 @@ def _decide(self, user_context, key, decide_options=None):
1047
1047
decision = Decision (None , variation , enums .DecisionSources .FEATURE_TEST )
1048
1048
else :
1049
1049
# Regular decision
1050
- decision = decision_service .DecisionService . get_variation_for_feature (self . decision_service , config ,
1051
- feature_flag ,
1052
- user_context , ignore_ups )
1053
- decision , decision_reasons = decision
1050
+ decision , decision_reasons = self . decision_service .get_variation_for_feature (config ,
1051
+ feature_flag ,
1052
+ user_context , ignore_ups )
1053
+
1054
1054
reasons += decision_reasons
1055
1055
1056
1056
# Fill in experiment and variation if returned (rollouts can have featureEnabled variables as well.)
@@ -1203,7 +1203,10 @@ def get_flag_variation_by_key(self, flag_key, variation_key):
1203
1203
if not config :
1204
1204
return None
1205
1205
1206
- variations = config .flag_variations_map [flag_key ]
1206
+ if not flag_key :
1207
+ return None
1208
+
1209
+ variations = config .flag_variations_map .get (flag_key )
1207
1210
1208
1211
for variation in variations :
1209
1212
if variation .key == variation_key :
0 commit comments