flagdock 0.3.3__tar.gz → 0.4.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.
- {flagdock-0.3.3 → flagdock-0.4.0}/PKG-INFO +1 -1
- {flagdock-0.3.3 → flagdock-0.4.0}/pyproject.toml +1 -1
- {flagdock-0.3.3 → flagdock-0.4.0}/src/flagdock/engine.py +31 -2
- {flagdock-0.3.3 → flagdock-0.4.0}/src/flagdock/provider.py +4 -3
- {flagdock-0.3.3 → flagdock-0.4.0}/.gitignore +0 -0
- {flagdock-0.3.3 → flagdock-0.4.0}/LICENSE +0 -0
- {flagdock-0.3.3 → flagdock-0.4.0}/README.md +0 -0
- {flagdock-0.3.3 → flagdock-0.4.0}/src/flagdock/__init__.py +0 -0
- {flagdock-0.3.3 → flagdock-0.4.0}/src/flagdock/_usage.py +0 -0
- {flagdock-0.3.3 → flagdock-0.4.0}/src/flagdock/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: flagdock
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Flagdock feature flags for Python: an OpenFeature provider that downloads the rules once and evaluates in memory
|
|
5
5
|
Project-URL: Homepage, https://flagdock.com
|
|
6
6
|
Author-email: Flagdock <info@flagdock.com>
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "flagdock"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "Flagdock feature flags for Python: an OpenFeature provider that downloads the rules once and evaluates in memory"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -461,6 +461,8 @@ class Resolution:
|
|
|
461
461
|
rule_index: Optional[int] = None
|
|
462
462
|
bucket: Optional[int] = None
|
|
463
463
|
prerequisite: Optional[str] = None
|
|
464
|
+
#: True when a rule's slice kept this person out (another test's people, or the holdout) and no later rule matched.
|
|
465
|
+
excluded: bool = False
|
|
464
466
|
|
|
465
467
|
def to_dict(self) -> dict[str, Any]:
|
|
466
468
|
"""The same keys the TypeScript engine uses, leaving out the ones that are not set."""
|
|
@@ -477,6 +479,8 @@ class Resolution:
|
|
|
477
479
|
v = getattr(self, name)
|
|
478
480
|
if v is not None:
|
|
479
481
|
out[key] = v
|
|
482
|
+
if self.excluded:
|
|
483
|
+
out["excluded"] = True
|
|
480
484
|
return out
|
|
481
485
|
|
|
482
486
|
|
|
@@ -530,6 +534,18 @@ def _rule_matches(
|
|
|
530
534
|
return False, None
|
|
531
535
|
|
|
532
536
|
|
|
537
|
+
def _in_slices(rule: Mapping[str, Any], context: Mapping[str, Any]) -> bool:
|
|
538
|
+
"""Whether the person's bucket for every slice of the rule is inside it."""
|
|
539
|
+
value = _bucket_value(rule, context)
|
|
540
|
+
for s in rule.get("slices") or []:
|
|
541
|
+
if value is None:
|
|
542
|
+
return False
|
|
543
|
+
bucket = rollout_bucket(s.get("salt"), value)
|
|
544
|
+
if not (s.get("from") <= bucket < s.get("to")):
|
|
545
|
+
return False
|
|
546
|
+
return True
|
|
547
|
+
|
|
548
|
+
|
|
533
549
|
def _pick_from_split(
|
|
534
550
|
split: Sequence[Mapping[str, Any]], rule: Mapping[str, Any], flag: Mapping[str, Any], context: Mapping[str, Any]
|
|
535
551
|
) -> Optional[str]:
|
|
@@ -609,6 +625,7 @@ def _evaluate_at(
|
|
|
609
625
|
rule_index: Optional[int] = None,
|
|
610
626
|
bucket: Optional[int] = None,
|
|
611
627
|
prerequisite: Optional[str] = None,
|
|
628
|
+
excluded: bool = False,
|
|
612
629
|
) -> tuple[Resolution, bool]:
|
|
613
630
|
if not isinstance(value_key, str) or value_key not in values:
|
|
614
631
|
return Resolution(
|
|
@@ -626,7 +643,14 @@ def _evaluate_at(
|
|
|
626
643
|
error_message=f'Value "{value_key}" of flag "{flag_key}" is not a {flag.get("kind")}',
|
|
627
644
|
), False
|
|
628
645
|
resolved = Resolution(
|
|
629
|
-
value,
|
|
646
|
+
value,
|
|
647
|
+
reason,
|
|
648
|
+
value_key=value_key,
|
|
649
|
+
rule_id=rule_id,
|
|
650
|
+
rule_index=rule_index,
|
|
651
|
+
bucket=bucket,
|
|
652
|
+
prerequisite=prerequisite,
|
|
653
|
+
excluded=excluded,
|
|
630
654
|
)
|
|
631
655
|
return resolved, False
|
|
632
656
|
|
|
@@ -654,8 +678,13 @@ def _evaluate_at(
|
|
|
654
678
|
return serve(flag.get("offValue"), "PREREQUISITE_FAILED", prerequisite=prerequisite.get("flag"))
|
|
655
679
|
|
|
656
680
|
last_bucket: Optional[int] = None
|
|
681
|
+
excluded = False
|
|
657
682
|
for i, rule in enumerate(flag.get("rules") or []):
|
|
658
683
|
matched, bucket = _rule_matches(rule, flag, ruleset, context)
|
|
684
|
+
# Slices only matter to someone the rule would otherwise take.
|
|
685
|
+
if matched and rule.get("slices") and not _in_slices(rule, context):
|
|
686
|
+
matched = False
|
|
687
|
+
excluded = True
|
|
659
688
|
if bucket is not None:
|
|
660
689
|
last_bucket = bucket
|
|
661
690
|
if not matched:
|
|
@@ -670,4 +699,4 @@ def _evaluate_at(
|
|
|
670
699
|
value_key = served.get("value") if isinstance(served, Mapping) and served.get("value") is not None else flag.get("matchValue")
|
|
671
700
|
return serve(value_key, "TARGETING_MATCH", rule.get("id"), i, bucket)
|
|
672
701
|
|
|
673
|
-
return serve(flag.get("defaultValue"), "DEFAULT", bucket=last_bucket)
|
|
702
|
+
return serve(flag.get("defaultValue"), "DEFAULT", bucket=last_bucket, excluded=excluded)
|
|
@@ -23,7 +23,7 @@ from . import engine
|
|
|
23
23
|
from ._usage import ActivityLog, UsageCounter
|
|
24
24
|
|
|
25
25
|
SDK_NAME = "python"
|
|
26
|
-
SDK_VERSION = "0.
|
|
26
|
+
SDK_VERSION = "0.4.0"
|
|
27
27
|
DEFAULT_URL = "https://edge.flagdock.com"
|
|
28
28
|
DEFAULT_FALLBACK_URL = "https://app.flagdock.com"
|
|
29
29
|
|
|
@@ -481,8 +481,9 @@ class FlagdockProvider(AbstractProvider):
|
|
|
481
481
|
if self._usage_interval > 0:
|
|
482
482
|
self._usage.record(flag_key, r.value_key)
|
|
483
483
|
user = ctx.get("targetingKey")
|
|
484
|
-
# Who got which value, so goals can be compared. Only for people the app identifies
|
|
485
|
-
|
|
484
|
+
# Who got which value, so goals can be compared. Only for people the app identifies, and not for
|
|
485
|
+
# people a slice kept out of a test (another test's people, or the holdout).
|
|
486
|
+
if r.value_key is not None and isinstance(user, str) and user != "" and not r.excluded:
|
|
486
487
|
self._activity.expose(flag_key, r.value_key, user)
|
|
487
488
|
if r.reason == "ERROR":
|
|
488
489
|
return r, FlagResolutionDetails(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|