Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
FF-3106 fix: ContextAttributes.from_dict() should not treat bool as n…
Browse files Browse the repository at this point in the history
…umeric (#67)
  • Loading branch information
rasendubi authored Aug 29, 2024
1 parent 4e88795 commit b4340bb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion eppo_client/bandit.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def from_dict(cls, attributes: Attributes):
numeric_attributes = {
key: float(value)
for key, value in attributes.items()
if isinstance(value, (int, float))
if isinstance(value, (int, float)) and not isinstance(value, bool)
}
categorical_attributes = {
key: to_string(value)
Expand Down
2 changes: 1 addition & 1 deletion eppo_client/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Note to developers: When ready to bump to 4.0, please change
# the `POLL_INTERVAL_SECONDS` constant in `eppo_client/constants.py`
# to 30 seconds to match the behavior of the other server SDKs.
__version__ = "3.5.3"
__version__ = "3.5.4"
14 changes: 14 additions & 0 deletions test/context_attributes_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from eppo_client.bandit import ContextAttributes


def test_from_dict_treats_bools_as_categorical():
attrs = ContextAttributes.from_dict(
{
"categorical": True,
}
)

assert attrs.categorical_attributes == {
"categorical": "true",
}
assert attrs.numeric_attributes == {}

0 comments on commit b4340bb

Please sign in to comment.