Skip to content

Commit 222f232

Browse files
author
Bilal Al
committed
polish
1 parent 2546181 commit 222f232

File tree

6 files changed

+20
-21
lines changed

6 files changed

+20
-21
lines changed

splitio/engine/evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def eval_with_context(self, key, bucketing, feature_name, attrs, ctx):
6868
'label': label,
6969
'change_number': _change_number
7070
},
71-
'impressions_disabled': feature.ImpressionsDisabled if feature else None
71+
'impressions_disabled': feature.impressionsDisabled if feature else None
7272
}
7373

7474
def _treatment_for_flag(self, flag, key, bucketing, attributes, ctx):

splitio/models/splits.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
SplitView = namedtuple(
1212
'SplitView',
13-
['name', 'traffic_type', 'killed', 'treatments', 'change_number', 'configs', 'default_treatment', 'sets', 'ImpressionsDisabled']
13+
['name', 'traffic_type', 'killed', 'treatments', 'change_number', 'configs', 'default_treatment', 'sets', 'impressions_disabled']
1414
)
1515

1616
_DEFAULT_CONDITIONS_TEMPLATE = {
@@ -74,7 +74,7 @@ def __init__( # pylint: disable=too-many-arguments
7474
traffic_allocation_seed=None,
7575
configurations=None,
7676
sets=None,
77-
ImpressionsDisabled=None
77+
impressionsDisabled=None
7878
):
7979
"""
8080
Class constructor.
@@ -97,8 +97,8 @@ def __init__( # pylint: disable=too-many-arguments
9797
:type traffic_allocation_seed: int
9898
:pram sets: list of flag sets
9999
:type sets: list
100-
:pram ImpressionsDisabled: track impressions flag
101-
:type ImpressionsDisabled: boolean
100+
:pram impressionsDisabled: track impressions flag
101+
:type impressionsDisabled: boolean
102102
"""
103103
self._name = name
104104
self._seed = seed
@@ -128,7 +128,7 @@ def __init__( # pylint: disable=too-many-arguments
128128

129129
self._configurations = configurations
130130
self._sets = set(sets) if sets is not None else set()
131-
self._ImpressionsDisabled = ImpressionsDisabled if ImpressionsDisabled is not None else False
131+
self._impressionsDisabled = impressionsDisabled if impressionsDisabled is not None else False
132132

133133
@property
134134
def name(self):
@@ -191,9 +191,9 @@ def sets(self):
191191
return self._sets
192192

193193
@property
194-
def ImpressionsDisabled(self):
195-
"""Return ImpressionsDisabled of the split."""
196-
return self._ImpressionsDisabled
194+
def impressionsDisabled(self):
195+
"""Return impressionsDisabled of the split."""
196+
return self._impressionsDisabled
197197

198198
def get_configurations_for(self, treatment):
199199
"""Return the mapping of treatments to configurations."""
@@ -224,7 +224,7 @@ def to_json(self):
224224
'conditions': [c.to_json() for c in self.conditions],
225225
'configurations': self._configurations,
226226
'sets': list(self._sets),
227-
'ImpressionsDisabled': self._ImpressionsDisabled
227+
'impressionsDisabled': self._impressionsDisabled
228228
}
229229

230230
def to_split_view(self):
@@ -243,7 +243,7 @@ def to_split_view(self):
243243
self._configurations if self._configurations is not None else {},
244244
self._default_treatment,
245245
list(self._sets) if self._sets is not None else [],
246-
self._ImpressionsDisabled
246+
self._impressionsDisabled
247247
)
248248

249249
def local_kill(self, default_treatment, change_number):
@@ -300,5 +300,5 @@ def from_raw(raw_split):
300300
traffic_allocation_seed=raw_split.get('trafficAllocationSeed'),
301301
configurations=raw_split.get('configurations'),
302302
sets=set(raw_split.get('sets')) if raw_split.get('sets') is not None else [],
303-
ImpressionsDisabled=raw_split.get('ImpressionsDisabled') if raw_split.get('ImpressionsDisabled') is not None else False
303+
impressionsDisabled=raw_split.get('impressionsDisabled') if raw_split.get('impressionsDisabled') is not None else False
304304
)

splitio/recorder/recorder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,8 @@ def record_treatment_stats(self, impressions_decorated, latency, operation, meth
174174
self._imp_counter.track(for_counter)
175175
if len(for_unique_keys_tracker) > 0:
176176
[self._unique_keys_tracker.track(item[0], item[1]) for item in for_unique_keys_tracker]
177-
except Exception as exc: # pylint: disable=broad-except
177+
except Exception: # pylint: disable=broad-except
178178
_LOGGER.error('Error recording impressions')
179-
_LOGGER.error(exc)
180179
_LOGGER.debug('Error: ', exc_info=True)
181180

182181
def record_track_stats(self, event, latency):

tests/engine/test_evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_evaluate_treatment_ok(self, mocker):
5252
assert result['impression']['change_number'] == 123
5353
assert result['impression']['label'] == 'some_label'
5454
assert mocked_split.get_configurations_for.mock_calls == [mocker.call('on')]
55-
assert result['impressions_disabled'] == mocked_split.ImpressionsDisabled
55+
assert result['impressions_disabled'] == mocked_split.impressionsDisabled
5656

5757

5858
def test_evaluate_treatment_ok_no_config(self, mocker):

tests/integration/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
split11 = {"splits": [
2-
{"trafficTypeName": "user", "name": "SPLIT_2","trafficAllocation": 100,"trafficAllocationSeed": 1057590779, "seed": -113875324, "status": "ACTIVE","killed": False, "defaultTreatment": "off", "changeNumber": 1675443569027,"algo": 2, "configurations": {},"conditions": [{"conditionType": "ROLLOUT","matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 100 },{ "treatment": "off", "size": 0 }],"label": "default rule"}], "sets": ["set_1"], "ImpressionsDisabled": False},
2+
{"trafficTypeName": "user", "name": "SPLIT_2","trafficAllocation": 100,"trafficAllocationSeed": 1057590779, "seed": -113875324, "status": "ACTIVE","killed": False, "defaultTreatment": "off", "changeNumber": 1675443569027,"algo": 2, "configurations": {},"conditions": [{"conditionType": "ROLLOUT","matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 100 },{ "treatment": "off", "size": 0 }],"label": "default rule"}], "sets": ["set_1"], "impressionsDisabled": False},
33
{"trafficTypeName": "user", "name": "SPLIT_1", "trafficAllocation": 100, "trafficAllocationSeed": -1780071202,"seed": -1442762199, "status": "ACTIVE","killed": False, "defaultTreatment": "off", "changeNumber": 1675443537882,"algo": 2, "configurations": {},"conditions": [{"conditionType": "ROLLOUT", "matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 0 },{ "treatment": "off", "size": 100 }],"label": "default rule"}], "sets": ["set_1", "set_2"]},
4-
{"trafficTypeName": "user", "name": "SPLIT_3","trafficAllocation": 100,"trafficAllocationSeed": 1057590779, "seed": -113875324, "status": "ACTIVE","killed": False, "defaultTreatment": "off", "changeNumber": 1675443569027,"algo": 2, "configurations": {},"conditions": [{"conditionType": "ROLLOUT","matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 100 },{ "treatment": "off", "size": 0 }],"label": "default rule"}], "sets": ["set_1"], "ImpressionsDisabled": True}
4+
{"trafficTypeName": "user", "name": "SPLIT_3","trafficAllocation": 100,"trafficAllocationSeed": 1057590779, "seed": -113875324, "status": "ACTIVE","killed": False, "defaultTreatment": "off", "changeNumber": 1675443569027,"algo": 2, "configurations": {},"conditions": [{"conditionType": "ROLLOUT","matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 100 },{ "treatment": "off", "size": 0 }],"label": "default rule"}], "sets": ["set_1"], "impressionsDisabled": True}
55
],"since": -1,"till": 1675443569027}
66
split12 = {"splits": [{"trafficTypeName": "user","name": "SPLIT_2","trafficAllocation": 100,"trafficAllocationSeed": 1057590779,"seed": -113875324,"status": "ACTIVE","killed": True,"defaultTreatment": "off","changeNumber": 1675443767288,"algo": 2,"configurations": {},"conditions": [{"conditionType": "ROLLOUT","matcherGroup": {"combiner": "AND","matchers": [{"keySelector": { "trafficType": "user", "attribute": None },"matcherType": "ALL_KEYS","negate": False,"userDefinedSegmentMatcherData": None,"whitelistMatcherData": None,"unaryNumericMatcherData": None,"betweenMatcherData": None,"booleanMatcherData": None,"dependencyMatcherData": None,"stringMatcherData": None}]},"partitions": [{ "treatment": "on", "size": 100 },{ "treatment": "off", "size": 0 }],"label": "default rule"}]}],"since": 1675443569027,"till": 167544376728}
77
split13 = {"splits": [

tests/models/test_splits.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class SplitTests(object):
6161
'on': '{"color": "blue", "size": 13}'
6262
},
6363
'sets': ['set1', 'set2'],
64-
'ImpressionsDisabled': False
64+
'impressionsDisabled': False
6565
}
6666

6767
def test_from_raw(self):
@@ -82,7 +82,7 @@ def test_from_raw(self):
8282
assert parsed.get_configurations_for('on') == '{"color": "blue", "size": 13}'
8383
assert parsed._configurations == {'on': '{"color": "blue", "size": 13}'}
8484
assert parsed.sets == {'set1', 'set2'}
85-
assert parsed.ImpressionsDisabled == False
85+
assert parsed.impressionsDisabled == False
8686

8787
def test_get_segment_names(self, mocker):
8888
"""Test fetching segment names."""
@@ -109,7 +109,7 @@ def test_to_json(self):
109109
assert as_json['algo'] == 2
110110
assert len(as_json['conditions']) == 2
111111
assert sorted(as_json['sets']) == ['set1', 'set2']
112-
assert as_json['ImpressionsDisabled'] is False
112+
assert as_json['impressionsDisabled'] is False
113113

114114
def test_to_split_view(self):
115115
"""Test SplitView creation."""
@@ -121,7 +121,7 @@ def test_to_split_view(self):
121121
assert as_split_view.traffic_type == self.raw['trafficTypeName']
122122
assert set(as_split_view.treatments) == set(['on', 'off'])
123123
assert sorted(as_split_view.sets) == sorted(list(self.raw['sets']))
124-
assert as_split_view.ImpressionsDisabled == self.raw['ImpressionsDisabled']
124+
assert as_split_view.impressions_disabled == self.raw['impressionsDisabled']
125125

126126
def test_incorrect_matcher(self):
127127
"""Test incorrect matcher in split model parsing."""

0 commit comments

Comments
 (0)