From 713ee3445f3351f02966f654e27325a69b441641 Mon Sep 17 00:00:00 2001 From: Oleksii Shmalko Date: Wed, 16 Oct 2024 19:52:57 +0300 Subject: [PATCH 1/2] fix: flatten "base" in event --- eppo_core/src/events.rs | 1 + python-sdk/tests/test_assignment_logger.py | 22 ++++++++++++++++++++++ python-sdk/tests/util.py | 4 ++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/eppo_core/src/events.rs b/eppo_core/src/events.rs index b8fcbafb..804f0bb6 100644 --- a/eppo_core/src/events.rs +++ b/eppo_core/src/events.rs @@ -38,6 +38,7 @@ pub struct AssignmentEventBase { #[derive(Debug, Clone, Serialize)] #[serde(rename_all = "camelCase")] pub struct AssignmentEvent { + #[serde(flatten)] pub base: Arc, /// The key identifying the subject receiving the assignment. pub subject: Str, diff --git a/python-sdk/tests/test_assignment_logger.py b/python-sdk/tests/test_assignment_logger.py index eb4bcd0d..bccc498a 100644 --- a/python-sdk/tests/test_assignment_logger.py +++ b/python-sdk/tests/test_assignment_logger.py @@ -2,6 +2,8 @@ from eppo_client.assignment_logger import AssignmentLogger +from .util import init + def test_can_inherit_assignment_logger(): class MyAssignmentLogger(AssignmentLogger): @@ -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": "alice@example.com"}, "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" diff --git a/python-sdk/tests/util.py b/python-sdk/tests/util.py index 6191d3ef..e32b4d10 100644 --- a/python-sdk/tests/util.py +++ b/python-sdk/tests/util.py @@ -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: From 606b372d4d5682861f7c5b800ac672416cc45c80 Mon Sep 17 00:00:00 2001 From: Oleksii Shmalko Date: Wed, 16 Oct 2024 19:55:37 +0300 Subject: [PATCH 2/2] chore: bump versions --- eppo_core/Cargo.toml | 2 +- python-sdk/Cargo.toml | 4 ++-- ruby-sdk/ext/eppo_client/Cargo.toml | 4 ++-- rust-sdk/Cargo.toml | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/eppo_core/Cargo.toml b/eppo_core/Cargo.toml index 6311f0f0..d2f9c0e2 100644 --- a/eppo_core/Cargo.toml +++ b/eppo_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "eppo_core" -version = "4.0.0" +version = "4.0.1" edition = "2021" description = "Eppo SDK core library" repository = "https://github.com/Eppo-exp/rust-sdk" diff --git a/python-sdk/Cargo.toml b/python-sdk/Cargo.toml index d205075e..b869c678 100644 --- a/python-sdk/Cargo.toml +++ b/python-sdk/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "eppo_py" -version = "4.0.2" +version = "4.0.3" edition = "2021" publish = false @@ -8,7 +8,7 @@ publish = false crate-type = ["cdylib"] [dependencies] -eppo_core = { version = "4.0.0", path = "../eppo_core", features = ["pyo3"] } +eppo_core = { version = "4.0.1", path = "../eppo_core", features = ["pyo3"] } log = "0.4.22" pyo3 = { version = "0.22.0" } pyo3-log = "0.11.0" diff --git a/ruby-sdk/ext/eppo_client/Cargo.toml b/ruby-sdk/ext/eppo_client/Cargo.toml index dfe96c39..6f9e5a63 100644 --- a/ruby-sdk/ext/eppo_client/Cargo.toml +++ b/ruby-sdk/ext/eppo_client/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "eppo_client" # TODO: this version and lib/eppo_client/version.rb should be in sync -version = "3.2.0" +version = "3.2.1" edition = "2021" license = "MIT" publish = false @@ -12,7 +12,7 @@ crate-type = ["cdylib"] [dependencies] env_logger = { version = "0.11.3", features = ["unstable-kv"] } -eppo_core = { version = "4.0.0" } +eppo_core = { version = "4.0.1" } log = { version = "0.4.21", features = ["kv_serde"] } magnus = { version = "0.6.4" } serde = { version = "1.0.203", features = ["derive"] } diff --git a/rust-sdk/Cargo.toml b/rust-sdk/Cargo.toml index ee9dde10..d3735cb6 100644 --- a/rust-sdk/Cargo.toml +++ b/rust-sdk/Cargo.toml @@ -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" @@ -11,7 +11,7 @@ categories = ["config"] rust-version = "1.71.1" [dependencies] -eppo_core = { version = "4.0.0", path = "../eppo_core" } +eppo_core = { version = "=4.0.1", path = "../eppo_core" } log = { version = "0.4.21", features = ["kv", "kv_serde"] } serde_json = "1.0.116"