From bcc992ddb16e374db9880901bd2cf441aa4413d1 Mon Sep 17 00:00:00 2001 From: Lisa Date: Wed, 3 Jul 2024 09:53:49 -0400 Subject: [PATCH 1/4] Rename BanditData fields from model_ -> bandit_model_ prefix --- eppo_client/client.py | 4 ++-- eppo_client/models.py | 6 +++--- eppo_client/version.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eppo_client/client.py b/eppo_client/client.py index cc7852c..4ae6f1f 100644 --- a/eppo_client/client.py +++ b/eppo_client/client.py @@ -339,7 +339,7 @@ def get_bandit_action_detail( subject_key, subject_attributes, action_contexts, - bandit_data.model_data, + bandit_data.bandit_model_data, ) # log bandit action @@ -350,7 +350,7 @@ def get_bandit_action_detail( "action": evaluation.action_key if evaluation else None, "actionProbability": evaluation.action_weight if evaluation else None, "optimalityGap": evaluation.optimality_gap if evaluation else None, - "modelVersion": bandit_data.model_version if evaluation else None, + "modelVersion": bandit_data.bandit_model_version if evaluation else None, "timestamp": datetime.datetime.utcnow().isoformat(), "subjectNumericAttributes": ( subject_attributes.numeric_attributes diff --git a/eppo_client/models.py b/eppo_client/models.py index ea4e75d..04204dc 100644 --- a/eppo_client/models.py +++ b/eppo_client/models.py @@ -96,7 +96,7 @@ class BanditModelData(SdkBaseModel): class BanditData(SdkBaseModel): bandit_key: str - model_name: str + bandit_model_name: str + bandit_model_version: str + bandit_model_data: BanditModelData updated_at: datetime - model_version: str - model_data: BanditModelData diff --git a/eppo_client/version.py b/eppo_client/version.py index 88c513e..903a158 100644 --- a/eppo_client/version.py +++ b/eppo_client/version.py @@ -1 +1 @@ -__version__ = "3.3.0" +__version__ = "3.4.0" From 70200c053d389668634cd1b8bc48fb2025e49440 Mon Sep 17 00:00:00 2001 From: Lisa Date: Wed, 3 Jul 2024 11:43:33 -0400 Subject: [PATCH 2/4] Fixing some existing test data changes, updating generated model field names. --- eppo_client/client.py | 2 +- test/client_bandit_test.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eppo_client/client.py b/eppo_client/client.py index 4ae6f1f..56141e1 100644 --- a/eppo_client/client.py +++ b/eppo_client/client.py @@ -350,7 +350,7 @@ def get_bandit_action_detail( "action": evaluation.action_key if evaluation else None, "actionProbability": evaluation.action_weight if evaluation else None, "optimalityGap": evaluation.optimality_gap if evaluation else None, - "modelVersion": bandit_data.bandit_model_version if evaluation else None, + "banditModelVersion": bandit_data.bandit_model_version if evaluation else None, "timestamp": datetime.datetime.utcnow().isoformat(), "subjectNumericAttributes": ( subject_attributes.numeric_attributes diff --git a/test/client_bandit_test.py b/test/client_bandit_test.py index a3176ae..64cb7c6 100644 --- a/test/client_bandit_test.py +++ b/test/client_bandit_test.py @@ -175,9 +175,9 @@ def test_bandit_generic_test_cases(test_case): flag, subject["subjectKey"], ContextAttributes( - numeric_attributes=subject["subjectAttributes"]["numeric_attributes"], + numeric_attributes=subject["subjectAttributes"]["numericAttributes"], categorical_attributes=subject["subjectAttributes"][ - "categorical_attributes" + "categoricalAttributes" ], ), { From 08ac8aa69bcb2ac390de0bb3063478f7e65fd42e Mon Sep 17 00:00:00 2001 From: Lisa Date: Wed, 3 Jul 2024 12:20:07 -0400 Subject: [PATCH 3/4] Add alias for field names. --- eppo_client/client.py | 2 +- eppo_client/models.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/eppo_client/client.py b/eppo_client/client.py index 56141e1..4ae6f1f 100644 --- a/eppo_client/client.py +++ b/eppo_client/client.py @@ -350,7 +350,7 @@ def get_bandit_action_detail( "action": evaluation.action_key if evaluation else None, "actionProbability": evaluation.action_weight if evaluation else None, "optimalityGap": evaluation.optimality_gap if evaluation else None, - "banditModelVersion": bandit_data.bandit_model_version if evaluation else None, + "modelVersion": bandit_data.bandit_model_version if evaluation else None, "timestamp": datetime.datetime.utcnow().isoformat(), "subjectNumericAttributes": ( subject_attributes.numeric_attributes diff --git a/eppo_client/models.py b/eppo_client/models.py index 04204dc..68aaafc 100644 --- a/eppo_client/models.py +++ b/eppo_client/models.py @@ -1,5 +1,6 @@ from datetime import datetime from enum import Enum +from pydantic import Field from typing import Dict, List, Optional from eppo_client.base_model import SdkBaseModel @@ -96,7 +97,7 @@ class BanditModelData(SdkBaseModel): class BanditData(SdkBaseModel): bandit_key: str - bandit_model_name: str - bandit_model_version: str - bandit_model_data: BanditModelData + bandit_model_name: str = Field(alias='modelName') + bandit_model_version: str = Field(alias='modelVersion') + bandit_model_data: BanditModelData = Field(alias='modelData') updated_at: datetime From a79c889762cc8715e427103f447e19fc0cb56545 Mon Sep 17 00:00:00 2001 From: Lisa Date: Wed, 3 Jul 2024 12:21:52 -0400 Subject: [PATCH 4/4] lint --- eppo_client/models.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eppo_client/models.py b/eppo_client/models.py index 68aaafc..54add2f 100644 --- a/eppo_client/models.py +++ b/eppo_client/models.py @@ -97,7 +97,7 @@ class BanditModelData(SdkBaseModel): class BanditData(SdkBaseModel): bandit_key: str - bandit_model_name: str = Field(alias='modelName') - bandit_model_version: str = Field(alias='modelVersion') - bandit_model_data: BanditModelData = Field(alias='modelData') + bandit_model_name: str = Field(alias="modelName") + bandit_model_version: str = Field(alias="modelVersion") + bandit_model_data: BanditModelData = Field(alias="modelData") updated_at: datetime