flagsmith-flag-engine 10.0.4__tar.gz → 10.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flagsmith_flag_engine-10.0.4/flagsmith_flag_engine.egg-info → flagsmith_flag_engine-10.2.0}/PKG-INFO +9 -1
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/README.md +8 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/context/types.py +1 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/result/types.py +2 -1
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/segments/evaluator.py +34 -30
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0/flagsmith_flag_engine.egg-info}/PKG-INFO +9 -1
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/setup.py +1 -1
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/LICENSE.txt +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/__init__.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/context/__init__.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/context/mappers.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/engine.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/py.typed +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/result/__init__.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/segments/__init__.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/segments/constants.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/segments/types.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/segments/utils.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/utils/__init__.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/utils/hashing.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/utils/json/__init__.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/utils/json/encoders.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/utils/semver.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/utils/types.py +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flagsmith_flag_engine.egg-info/SOURCES.txt +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flagsmith_flag_engine.egg-info/dependency_links.txt +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flagsmith_flag_engine.egg-info/requires.txt +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flagsmith_flag_engine.egg-info/top_level.txt +0 -0
- {flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flagsmith-flag-engine
|
|
3
|
-
Version: 10.0
|
|
3
|
+
Version: 10.2.0
|
|
4
4
|
Summary: Flag engine for the Flagsmith API.
|
|
5
5
|
Home-page: https://github.com/Flagsmith/flagsmith-engine
|
|
6
6
|
Author: Flagsmith
|
|
@@ -46,6 +46,14 @@ source .venv/bin/activate
|
|
|
46
46
|
python -m pip install -r requirements-dev.txt
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
## Syncing engine-test-data
|
|
50
|
+
|
|
51
|
+
The engine-test-data submodule is pinned to a specific tag. To sync it locally:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
make sync-engine-test-data
|
|
55
|
+
```
|
|
56
|
+
|
|
49
57
|
## Design
|
|
50
58
|
|
|
51
59
|
- Marshmallow Schemas
|
|
@@ -15,6 +15,14 @@ source .venv/bin/activate
|
|
|
15
15
|
python -m pip install -r requirements-dev.txt
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
## Syncing engine-test-data
|
|
19
|
+
|
|
20
|
+
The engine-test-data submodule is pinned to a specific tag. To sync it locally:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
make sync-engine-test-data
|
|
24
|
+
```
|
|
25
|
+
|
|
18
26
|
## Design
|
|
19
27
|
|
|
20
28
|
- Marshmallow Schemas
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
-
from typing import Any, Dict, Generic, List
|
|
7
|
+
from typing import Any, Dict, Generic, List, Optional
|
|
8
8
|
|
|
9
9
|
from typing_extensions import NotRequired, TypedDict
|
|
10
10
|
|
|
@@ -16,6 +16,7 @@ class FlagResult(TypedDict, Generic[FeatureMetadataT]):
|
|
|
16
16
|
enabled: bool
|
|
17
17
|
value: Any
|
|
18
18
|
reason: str
|
|
19
|
+
variant: Optional[str]
|
|
19
20
|
metadata: NotRequired[FeatureMetadataT]
|
|
20
21
|
|
|
21
22
|
|
{flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/segments/evaluator.py
RENAMED
|
@@ -178,38 +178,39 @@ def get_flag_result_from_context(
|
|
|
178
178
|
"""
|
|
179
179
|
key = _get_identity_key(context)
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
value = feature_context["value"]
|
|
182
|
+
variant: typing.Optional[str] = None
|
|
182
183
|
|
|
183
184
|
if key is not None and (variants := feature_context.get("variants")):
|
|
185
|
+
# Default to the control bucket; a matched named variant overrides this.
|
|
186
|
+
variant = "control"
|
|
187
|
+
|
|
184
188
|
percentage_value = get_hashed_percentage_for_object_ids(
|
|
185
189
|
[feature_context["key"], key]
|
|
186
190
|
)
|
|
187
191
|
|
|
188
192
|
start_percentage = 0.0
|
|
189
193
|
|
|
190
|
-
for
|
|
194
|
+
for feature_value in sorted(
|
|
191
195
|
variants,
|
|
192
196
|
key=operator.itemgetter("priority"),
|
|
193
197
|
):
|
|
194
|
-
limit = (weight :=
|
|
198
|
+
limit = (weight := feature_value["weight"]) + start_percentage
|
|
195
199
|
if start_percentage <= percentage_value < limit:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
"reason": f"SPLIT; weight={weight}",
|
|
200
|
-
"value": variant["value"],
|
|
201
|
-
}
|
|
200
|
+
reason = f"SPLIT; weight={weight}"
|
|
201
|
+
value = feature_value["value"]
|
|
202
|
+
variant = feature_value.get("key")
|
|
202
203
|
break
|
|
203
204
|
|
|
204
205
|
start_percentage = limit
|
|
205
206
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
flag_result: FlagResult[FeatureMetadataT] = {
|
|
208
|
+
"enabled": feature_context["enabled"],
|
|
209
|
+
"name": feature_context["name"],
|
|
210
|
+
"reason": reason,
|
|
211
|
+
"value": value,
|
|
212
|
+
"variant": variant,
|
|
213
|
+
}
|
|
213
214
|
|
|
214
215
|
if metadata := feature_context.get("metadata"):
|
|
215
216
|
flag_result["metadata"] = metadata
|
|
@@ -236,27 +237,30 @@ def context_matches_rule(
|
|
|
236
237
|
) -> bool:
|
|
237
238
|
matches_conditions = (
|
|
238
239
|
get_matching_function(rule["type"])(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
for condition in conditions
|
|
246
|
-
]
|
|
240
|
+
context_matches_condition(
|
|
241
|
+
context=context,
|
|
242
|
+
condition=condition,
|
|
243
|
+
segment_key=segment_key,
|
|
244
|
+
)
|
|
245
|
+
for condition in conditions
|
|
247
246
|
)
|
|
248
247
|
if (conditions := rule.get("conditions"))
|
|
249
248
|
else True
|
|
250
249
|
)
|
|
251
250
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
251
|
+
matches_rules = (
|
|
252
|
+
get_matching_function(rule["type"])(
|
|
253
|
+
context_matches_rule(
|
|
254
|
+
context=context,
|
|
255
|
+
rule=sub_rule,
|
|
256
|
+
segment_key=segment_key,
|
|
257
|
+
)
|
|
258
|
+
for sub_rule in rules
|
|
257
259
|
)
|
|
258
|
-
|
|
260
|
+
if (rules := rule.get("rules"))
|
|
261
|
+
else True
|
|
259
262
|
)
|
|
263
|
+
return matches_conditions and matches_rules
|
|
260
264
|
|
|
261
265
|
|
|
262
266
|
def context_matches_condition(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flagsmith-flag-engine
|
|
3
|
-
Version: 10.0
|
|
3
|
+
Version: 10.2.0
|
|
4
4
|
Summary: Flag engine for the Flagsmith API.
|
|
5
5
|
Home-page: https://github.com/Flagsmith/flagsmith-engine
|
|
6
6
|
Author: Flagsmith
|
|
@@ -46,6 +46,14 @@ source .venv/bin/activate
|
|
|
46
46
|
python -m pip install -r requirements-dev.txt
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
## Syncing engine-test-data
|
|
50
|
+
|
|
51
|
+
The engine-test-data submodule is pinned to a specific tag. To sync it locally:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
make sync-engine-test-data
|
|
55
|
+
```
|
|
56
|
+
|
|
49
57
|
## Design
|
|
50
58
|
|
|
51
59
|
- Marshmallow Schemas
|
|
File without changes
|
|
File without changes
|
{flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/context/__init__.py
RENAMED
|
File without changes
|
{flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/context/mappers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/result/__init__.py
RENAMED
|
File without changes
|
{flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/segments/__init__.py
RENAMED
|
File without changes
|
{flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/segments/constants.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/utils/json/__init__.py
RENAMED
|
File without changes
|
{flagsmith_flag_engine-10.0.4 → flagsmith_flag_engine-10.2.0}/flag_engine/utils/json/encoders.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|