Skip to content

Commit b2d63e6

Browse files
committed
Merge branch 'perf/local-eval-regression' into feat/flags-context-values
# Conflicts: # flagsmith/local_evaluation.py
2 parents cf7bbae + e80d1c4 commit b2d63e6

4 files changed

Lines changed: 5 additions & 16 deletions

File tree

‎flagsmith/flagsmith.py‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,6 @@ def get_identity_segments(
338338
"Local evaluation required to obtain identity segments."
339339
)
340340

341-
# Identity overrides segments are left out: they aren't segments
342-
# in Flagsmith, so they're never returned.
343341
context = map_context_and_identity_data_to_context(
344342
context=local_evaluation.context,
345343
identifier=identifier,
@@ -497,8 +495,6 @@ def _get_environment_flags_from_document(self) -> Flags:
497495
if (local_evaluation := self._local_evaluation) is None:
498496
raise TypeError("No environment present")
499497

500-
# Evaluated once per environment document. `Flag` instances are
501-
# shared across calls; the mapping holding them is not.
502498
return Flags(
503499
flags=dict(local_evaluation.environment_flags),
504500
default_flag_handler=self.default_flag_handler,

‎flagsmith/local_evaluation.py‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,7 @@ def _get_context_reads(rules: typing.Iterable[SegmentRule]) -> _ContextReads:
5757

5858

5959
class LocalEvaluation:
60-
"""Per-environment-document state for local evaluation.
61-
62-
Built once each time the environment document is refreshed, so the
63-
work here is amortised across every evaluation until the next refresh.
64-
65-
Identity overrides are kept out of the context, by identifier. Each
66-
identity is evaluated with its own identity overrides segment only.
67-
"""
60+
"""Per-environment-document state for local evaluation."""
6861

6962
def __init__(
7063
self,

‎flagsmith/mappers.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
)
3030
from flagsmith.utils.datetime import fromisoformat
3131

32-
# Each identity is evaluated with its own identity overrides segment only.
3332
IDENTITY_OVERRIDES_SEGMENT_KEY = "identity_overrides"
3433

3534

‎tests/test_streaming_manager.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pytest_mock import MockerFixture
88

99
from flagsmith import Flagsmith
10+
from flagsmith.local_evaluation import LocalEvaluation
1011
from flagsmith.streaming_manager import EventStreamManager
1112
from flagsmith.types import StreamEvent
1213

@@ -44,7 +45,7 @@ def test_environment_updates_on_recent_event(
4445
mocker.patch("flagsmith.Flagsmith.update_environment")
4546

4647
flagsmith = Flagsmith(environment_key=server_api_key)
47-
flagsmith._local_evaluation = MagicMock()
48+
flagsmith._local_evaluation = MagicMock(spec=LocalEvaluation)
4849
flagsmith._environment_updated_at = environment_updated_at
4950
flagsmith.handle_stream_event(event=StreamEvent(updated_at=stream_updated_at))
5051
assert isinstance(flagsmith.update_environment, Mock)
@@ -60,7 +61,7 @@ def test_environment_does_not_update_on_past_event(
6061
mocker.patch("flagsmith.Flagsmith.update_environment")
6162

6263
flagsmith = Flagsmith(environment_key=server_api_key)
63-
flagsmith._local_evaluation = MagicMock()
64+
flagsmith._local_evaluation = MagicMock(spec=LocalEvaluation)
6465
flagsmith._environment_updated_at = environment_updated_at
6566

6667
flagsmith.handle_stream_event(event=StreamEvent(updated_at=stream_updated_at))
@@ -77,7 +78,7 @@ def test_environment_does_not_update_on_same_event(
7778
mocker.patch("flagsmith.Flagsmith.update_environment")
7879

7980
flagsmith = Flagsmith(environment_key=server_api_key)
80-
flagsmith._local_evaluation = MagicMock()
81+
flagsmith._local_evaluation = MagicMock(spec=LocalEvaluation)
8182
flagsmith._environment_updated_at = environment_updated_at
8283

8384
flagsmith.handle_stream_event(event=StreamEvent(updated_at=stream_updated_at))

0 commit comments

Comments
 (0)