44from splitio .splitters import Splitter
55from splitio .key import Key
66from splitio .treatments import CONTROL
7- from . import input_validator
87
98
109class Evaluator (object ):
@@ -27,13 +26,13 @@ def evaluate_treatment(self, feature, matching_key, bucketing_key, attributes=No
2726 Evaluates the user submitted data against a feature and return the resulting treatment.
2827
2928 :param feature: The feature for which to get the treatment
30- :type string: feature
29+ :type feature: str
3130
3231 :param matching_key: The matching_key for which to get the treatment
33- :type string : str
32+ :type matching_key : str
3433
3534 :param bucketing_key: The bucketing_key for which to get the treatment
36- :type string : str
35+ :type bucketing_key : str
3736
3837 :param attributes: An optional dictionary of attributes
3938 :type attributes: dict
@@ -131,44 +130,3 @@ def get_treatment_for_split(self, split, matching_key, bucketing_key, attributes
131130
132131 # No condition matches
133132 return None , None
134-
135- def get_treatment (self , key , feature , attributes = None ):
136- """
137- Evaluate a feature and return the appropriate traetment.
138- Will not generate impressions nor metrics
139- :param key: user key
140- :type key: mixed
141- :param feature: feature name
142- :type feature: str
143- :param attributes: (Optional) attributes associated with the user key
144- :type attributes: dict
145- """
146- matching_key , bucketing_key = input_validator .validate_key (key )
147- feature = input_validator .validate_feature_name (feature )
148- if (matching_key is None and bucketing_key is None ) or feature is None :
149- return CONTROL
150- try :
151- # Fetching Split definition
152- split = self ._broker .fetch_feature (feature )
153- if split is None :
154- self ._logger .warning (
155- 'Unknown or invalid dependent feature: %s' ,
156- feature
157- )
158- return CONTROL
159- if split .killed :
160- return split .default_treatment
161- treatment , _ = self .get_treatment_for_split (
162- split ,
163- matching_key ,
164- bucketing_key ,
165- attributes
166- )
167- if treatment is None :
168- return split .default_treatment
169- return treatment
170- except Exception : # pylint: disable=broad-except
171- self ._logger .exception (
172- 'Exception caught retrieving dependent feature. Returning CONTROL'
173- )
174- return CONTROL
0 commit comments