@@ -78,7 +78,7 @@ def _evaluate_if_ready(self, matching_key, bucketing_key, feature, attributes=No
7878 attributes
7979 )
8080
81- def _make_evaluation (self , key , feature , attributes , method_name , metric_name ):
81+ def _make_evaluation (self , key , feature_flag , attributes , method_name , metric_name ):
8282 try :
8383 if self .destroyed :
8484 _LOGGER .error ("Client has already been destroyed - no calls possible" )
@@ -90,23 +90,23 @@ def _make_evaluation(self, key, feature, attributes, method_name, metric_name):
9090 start = get_current_epoch_time_ms ()
9191
9292 matching_key , bucketing_key = input_validator .validate_key (key , method_name )
93- feature = input_validator .validate_feature_name (
94- feature ,
93+ feature_flag = input_validator .validate_feature_name (
94+ feature_flag ,
9595 self .ready ,
9696 self ._factory ._get_storage ('splits' ), # pylint: disable=protected-access
9797 method_name
9898 )
9999
100100 if (matching_key is None and bucketing_key is None ) \
101- or feature is None \
101+ or feature_flag is None \
102102 or not input_validator .validate_attributes (attributes , method_name ):
103103 return CONTROL , None
104104
105- result = self ._evaluate_if_ready (matching_key , bucketing_key , feature , attributes )
105+ result = self ._evaluate_if_ready (matching_key , bucketing_key , feature_flag , attributes )
106106
107107 impression = self ._build_impression (
108108 matching_key ,
109- feature ,
109+ feature_flag ,
110110 result ['treatment' ],
111111 result ['impression' ]['label' ],
112112 result ['impression' ]['change_number' ],
@@ -123,7 +123,7 @@ def _make_evaluation(self, key, feature, attributes, method_name, metric_name):
123123 try :
124124 impression = self ._build_impression (
125125 matching_key ,
126- feature ,
126+ feature_flag ,
127127 CONTROL ,
128128 Label .EXCEPTION ,
129129 self ._split_storage .get_change_number (),
@@ -136,57 +136,57 @@ def _make_evaluation(self, key, feature, attributes, method_name, metric_name):
136136 _LOGGER .debug ('Error: ' , exc_info = True )
137137 return CONTROL , None
138138
139- def _make_evaluations (self , key , features , attributes , method_name , metric_name ):
139+ def _make_evaluations (self , key , feature_flags , attributes , method_name , metric_name ):
140140 if self .destroyed :
141141 _LOGGER .error ("Client has already been destroyed - no calls possible" )
142- return input_validator .generate_control_treatments (features , method_name )
142+ return input_validator .generate_control_treatments (feature_flags , method_name )
143143 if self ._factory ._waiting_fork ():
144144 _LOGGER .error ("Client is not ready - no calls possible" )
145- return input_validator .generate_control_treatments (features , method_name )
145+ return input_validator .generate_control_treatments (feature_flags , method_name )
146146
147147 start = get_current_epoch_time_ms ()
148148
149149 matching_key , bucketing_key = input_validator .validate_key (key , method_name )
150150 if matching_key is None and bucketing_key is None :
151- return input_validator .generate_control_treatments (features , method_name )
151+ return input_validator .generate_control_treatments (feature_flags , method_name )
152152
153153 if input_validator .validate_attributes (attributes , method_name ) is False :
154- return input_validator .generate_control_treatments (features , method_name )
154+ return input_validator .generate_control_treatments (feature_flags , method_name )
155155
156- features , missing = input_validator .validate_features_get_treatments (
156+ feature_flags , missing = input_validator .validate_features_get_treatments (
157157 method_name ,
158- features ,
158+ feature_flags ,
159159 self .ready ,
160160 self ._factory ._get_storage ('splits' ) # pylint: disable=protected-access
161161 )
162- if features is None :
162+ if feature_flags is None :
163163 return {}
164164
165165 bulk_impressions = []
166166 treatments = {name : (CONTROL , None ) for name in missing }
167167
168168 try :
169169 evaluations = self ._evaluate_features_if_ready (matching_key , bucketing_key ,
170- list (features ), attributes )
170+ list (feature_flags ), attributes )
171171
172- for feature in features :
172+ for feature_flag in feature_flags :
173173 try :
174- result = evaluations [feature ]
174+ result = evaluations [feature_flag ]
175175 impression = self ._build_impression (matching_key ,
176- feature ,
176+ feature_flag ,
177177 result ['treatment' ],
178178 result ['impression' ]['label' ],
179179 result ['impression' ]['change_number' ],
180180 bucketing_key ,
181181 utctime_ms ())
182182
183183 bulk_impressions .append (impression )
184- treatments [feature ] = (result ['treatment' ], result ['configurations' ])
184+ treatments [feature_flag ] = (result ['treatment' ], result ['configurations' ])
185185
186186 except Exception : # pylint: disable=broad-except
187187 _LOGGER .error ('%s: An exception occured when evaluating '
188- 'feature flag %s returning CONTROL.' % (method_name , feature ))
189- treatments [feature ] = CONTROL , None
188+ 'feature flag %s returning CONTROL.' % (method_name , feature_flag ))
189+ treatments [feature_flag ] = CONTROL , None
190190 _LOGGER .debug ('Error: ' , exc_info = True )
191191 continue
192192
@@ -210,28 +210,28 @@ def _make_evaluations(self, key, features, attributes, method_name, metric_name)
210210 self ._telemetry_evaluation_producer .record_exception (metric_name )
211211 _LOGGER .error ('Error getting treatment for feature flags' )
212212 _LOGGER .debug ('Error: ' , exc_info = True )
213- return input_validator .generate_control_treatments (list (features ), method_name )
213+ return input_validator .generate_control_treatments (list (feature_flags ), method_name )
214214
215- def _evaluate_features_if_ready (self , matching_key , bucketing_key , features , attributes = None ):
215+ def _evaluate_features_if_ready (self , matching_key , bucketing_key , feature_flags , attributes = None ):
216216 if not self .ready :
217217 self ._telemetry_init_producer .record_not_ready_usage ()
218218 return {
219- feature : {
219+ feature_flag : {
220220 'treatment' : CONTROL ,
221221 'configurations' : None ,
222222 'impression' : {'label' : Label .NOT_READY , 'change_number' : None }
223223 }
224- for feature in features
224+ for feature_flag in feature_flags
225225 }
226226
227227 return self ._evaluator .evaluate_features (
228- features ,
228+ feature_flags ,
229229 matching_key ,
230230 bucketing_key ,
231231 attributes
232232 )
233233
234- def get_treatment_with_config (self , key , feature , attributes = None ):
234+ def get_treatment_with_config (self , key , feature_flag , attributes = None ):
235235 """
236236 Get the treatment and config for a feature flag and key, with optional dictionary of attributes.
237237
@@ -247,10 +247,10 @@ def get_treatment_with_config(self, key, feature, attributes=None):
247247 :return: The treatment for the key and feature flag
248248 :rtype: tuple(str, str)
249249 """
250- return self ._make_evaluation (key , feature , attributes , 'get_treatment_with_config' ,
250+ return self ._make_evaluation (key , feature_flag , attributes , 'get_treatment_with_config' ,
251251 MethodExceptionsAndLatencies .TREATMENT_WITH_CONFIG )
252252
253- def get_treatment (self , key , feature , attributes = None ):
253+ def get_treatment (self , key , feature_flag , attributes = None ):
254254 """
255255 Get the treatment for a feature flag and key, with an optional dictionary of attributes.
256256
@@ -266,11 +266,11 @@ def get_treatment(self, key, feature, attributes=None):
266266 :return: The treatment for the key and feature flag
267267 :rtype: str
268268 """
269- treatment , _ = self ._make_evaluation (key , feature , attributes , 'get_treatment' ,
269+ treatment , _ = self ._make_evaluation (key , feature_flag , attributes , 'get_treatment' ,
270270 MethodExceptionsAndLatencies .TREATMENT )
271271 return treatment
272272
273- def get_treatments_with_config (self , key , features , attributes = None ):
273+ def get_treatments_with_config (self , key , feature_flags , attributes = None ):
274274 """
275275 Evaluate multiple feature flags and return a dict with feature flag -> (treatment, config).
276276
@@ -286,10 +286,10 @@ def get_treatments_with_config(self, key, features, attributes=None):
286286 :return: Dictionary with the result of all the feature flags provided
287287 :rtype: dict
288288 """
289- return self ._make_evaluations (key , features , attributes , 'get_treatments_with_config' ,
289+ return self ._make_evaluations (key , feature_flags , attributes , 'get_treatments_with_config' ,
290290 MethodExceptionsAndLatencies .TREATMENTS_WITH_CONFIG )
291291
292- def get_treatments (self , key , features , attributes = None ):
292+ def get_treatments (self , key , feature_flags , attributes = None ):
293293 """
294294 Evaluate multiple feature flags and return a dictionary with all the feature flag/treatments.
295295
@@ -305,14 +305,14 @@ def get_treatments(self, key, features, attributes=None):
305305 :return: Dictionary with the result of all the feature flags provided
306306 :rtype: dict
307307 """
308- with_config = self ._make_evaluations (key , features , attributes , 'get_treatments' ,
308+ with_config = self ._make_evaluations (key , feature_flags , attributes , 'get_treatments' ,
309309 MethodExceptionsAndLatencies .TREATMENTS )
310- return {feature : result [0 ] for (feature , result ) in with_config .items ()}
310+ return {feature_flag : result [0 ] for (feature_flag , result ) in with_config .items ()}
311311
312312 def _build_impression ( # pylint: disable=too-many-arguments
313313 self ,
314314 matching_key ,
315- feature_name ,
315+ feature_flag_name ,
316316 treatment ,
317317 label ,
318318 change_number ,
@@ -324,7 +324,7 @@ def _build_impression( # pylint: disable=too-many-arguments
324324 label = None
325325
326326 return Impression (
327- matching_key = matching_key , feature_name = feature_name ,
327+ matching_key = matching_key , feature_name = feature_flag_name ,
328328 treatment = treatment , label = label , change_number = change_number ,
329329 bucketing_key = bucketing_key , time = imp_time
330330 )
0 commit comments