Skip to content

Commit 04ce9c0

Browse files
authored
FFM-11655 Sort AND/OR rules when storing group (#96)
* FFM-11655 Sort serving rules when storing segment instead of in evaluation path * FFM-11655 Backport for 3.7 * FFM-11655 1.6.2 version bump * FFM-11655 Fix compatability issues with python 3.7 * FFM-11655 Fix typo in setup requirements
1 parent cd5c942 commit 04ce9c0

File tree

10 files changed

+21
-14
lines changed

10 files changed

+21
-14
lines changed

featureflags/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__author__ = """Harness"""
44
__email__ = "support@harness.io"
5-
__version__ = '1.6.1'
5+
__version__ = '1.6.2'

featureflags/analytics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
VARIATION_VALUE_ATTRIBUTE = 'variationValue'
3939
TARGET_ATTRIBUTE = 'target'
4040
SDK_VERSION_ATTRIBUTE = 'SDK_VERSION'
41-
SDK_VERSION = '1.6.1'
41+
SDK_VERSION = '1.6.2'
4242
SDK_TYPE_ATTRIBUTE = 'SDK_TYPE'
4343
SDK_TYPE = 'server'
4444
SDK_LANGUAGE_ATTRIBUTE = 'SDK_LANGUAGE'

featureflags/api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from tenacity import retry_if_result, wait_exponential, \
22
stop_after_attempt, retry, retry_if_exception_type
33
from http import HTTPStatus
4-
from typing import Any, Union
4+
from typing import Any, Union, List
55

66
from .openapi.config.api.client.authenticate import \
77
sync_detailed as authenticate
@@ -115,7 +115,7 @@ def retryable_authenticate(
115115
def retryable_retrieve_segments(environment_uuid: str,
116116
client: AuthenticatedClient,
117117
cluster: Union[Unset, str] = UNSET) -> \
118-
Response[list[Segment]]:
118+
Response[List[Segment]]:
119119
return retrieve_segments(client=client,
120120
environment_uuid=environment_uuid,
121121
cluster=cluster,
@@ -129,7 +129,7 @@ def retryable_retrieve_segments(environment_uuid: str,
129129
def retryable_retrieve_feature_config(environment_uuid: str,
130130
client: AuthenticatedClient,
131131
cluster: Union[Unset, str] = UNSET) -> \
132-
Response[list[FeatureConfig]]:
132+
Response[List[FeatureConfig]]:
133133
return retrieve_flags(client=client,
134134
environment_uuid=environment_uuid,
135135
cluster=cluster)

featureflags/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from .streaming import StreamProcessor
2424
from .util import log
2525

26-
VERSION: str = "1.6.1"
26+
VERSION: str = "1.6.2"
2727

2828

2929
class MissingOrEmptyAPIKeyException(Exception):

featureflags/evaluations/evaluator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,8 @@ def _check_target_in_segment(self, segments: List[str],
181181
return True
182182

183183
if segment.serving_rules:
184-
log.debug('Found and using enhanced serving_rules')
185184
# Use enhanced rules first if they're available
186-
segment.serving_rules.sort(key=lambda rule: rule.priority)
185+
log.debug('Found and using enhanced serving_rules')
187186

188187
for serving_rule in segment.serving_rules:
189188
if self._evaluate_clauses_v2(serving_rule.clauses,
@@ -251,7 +250,7 @@ def _evaluate_clauses(self, clauses: Union[Unset, Clauses],
251250
log.debug("All clauses %s evaluated", clauses)
252251
return False
253252

254-
def _evaluate_clauses_v2(self, clauses: Union[Unset, Clauses],
253+
def _evaluate_clauses_v2(self, clauses: List[Clause],
255254
target: Target) -> bool:
256255
if not clauses or isinstance(clauses, Unset):
257256
return False

featureflags/openapi/config/types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
from typing import (
55
BinaryIO,
66
Generic,
7-
Literal,
87
MutableMapping,
98
Optional,
109
Tuple,
1110
TypeVar,
1211
)
1312

13+
from typing_extensions import Literal
14+
1415
from attrs import define
1516

1617

featureflags/openapi/metrics/types.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
from typing import (
55
BinaryIO,
66
Generic,
7-
Literal,
87
MutableMapping,
98
Optional,
109
Tuple,
1110
TypeVar,
1211
)
1312

13+
from typing_extensions import Literal
14+
15+
1416
from attrs import define
1517

1618

featureflags/repository.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ def set_segment(self, segment: Segment) -> None:
147147
log.debug("Segment %s already exists", segment.identifier)
148148
return None
149149

150+
# Sort the serving rules by priority
151+
if segment.serving_rules is not Unset:
152+
segment.serving_rules.sort(key=lambda rule: rule.priority)
153+
150154
segment_key = format_segment_key(segment.identifier)
151155

152156
if self.store:

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.6.1
2+
current_version = 1.6.2
33
commit = True
44
tag = True
55

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"attrs>=23.2.0",
1919
"mmh3>=3.0.0",
2020
"requests>=2.31.0",
21-
"tenacity==8.2.2"
21+
"tenacity==8.2.2",
22+
"typing_extensions==4.12.2"
2223
]
2324

2425
setup_requirements = [
@@ -57,6 +58,6 @@
5758
test_suite="tests",
5859
tests_require=test_requirements,
5960
url="https://github.com/harness/ff-python-server-sdk",
60-
version='1.6.1',
61+
version='1.6.2',
6162
zip_safe=False,
6263
)

0 commit comments

Comments
 (0)