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

FF-3106 fix: ContextAttributes.from_dict() should not treat bool as numeric #67

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumped the version as 3.5.3 was just released

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 == {}
Loading