Skip to content

Commit

Permalink
fix: flatten "base" in AssignmentEvent (#46)
Browse files Browse the repository at this point in the history
* fix: flatten "base" in event

* chore: bump versions
  • Loading branch information
rasendubi authored Oct 16, 2024
1 parent c1117b8 commit a2786af
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions eppo_core/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct AssignmentEventBase {
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AssignmentEvent {
#[serde(flatten)]
pub base: Arc<AssignmentEventBase>,
/// The key identifying the subject receiving the assignment.
pub subject: Str,
Expand Down
2 changes: 1 addition & 1 deletion python-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "eppo_py"
version = "4.0.2"
version = "4.0.3"
edition = "2021"
publish = false

Expand Down
22 changes: 22 additions & 0 deletions python-sdk/tests/test_assignment_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from eppo_client.assignment_logger import AssignmentLogger

from .util import init


def test_can_inherit_assignment_logger():
class MyAssignmentLogger(AssignmentLogger):
Expand All @@ -27,3 +29,23 @@ def test_has_log_assignment():

def test_has_log_bandit_action():
AssignmentLogger().log_bandit_action({})


def test_event_format():
event = None

class MyAssignmentLogger(AssignmentLogger):
def log_assignment(self, assignment_event: Dict):
nonlocal event
event = assignment_event

client = init("ufc", assignment_logger=MyAssignmentLogger())
result = client.get_string_assignment(
"regex-flag", "alice", {"email": "[email protected]"}, "default"
)
assert result == "partial-example"

assert event["allocation"] == "partial-example"
assert event["featureFlag"] == "regex-flag"
assert event["experiment"] == "regex-flag-partial-example"
assert event["metaData"]["sdkName"] == "python"
4 changes: 2 additions & 2 deletions python-sdk/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from eppo_client.config import Config, AssignmentLogger


def init(suite, *, wait_for_init=True):
def init(suite, *, wait_for_init=True, assignment_logger=AssignmentLogger()):
client = eppo_client.init(
Config(
api_key="blah",
base_url=f"http://localhost:8378/{suite}/api",
assignment_logger=AssignmentLogger(),
assignment_logger=assignment_logger,
)
)
if wait_for_init:
Expand Down
4 changes: 2 additions & 2 deletions rust-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "eppo"
version = "4.0.0"
version = "4.0.1"
edition = "2021"
description = "Eppo SDK for Rust"
homepage = "https://docs.geteppo.com/sdks/server-sdks/rust"
Expand All @@ -11,7 +11,7 @@ categories = ["config"]
rust-version = "1.71.1"

[dependencies]
eppo_core = { version = "4.1.0", path = "../eppo_core" }
eppo_core = { version = "=4.1.0", path = "../eppo_core" }
log = { version = "0.4.21", features = ["kv", "kv_serde"] }
serde_json = "1.0.116"

Expand Down

0 comments on commit a2786af

Please sign in to comment.