From 6b94b24d07619bb4bea7608e6e0e4ef764d2fb32 Mon Sep 17 00:00:00 2001 From: Sven Schmit Date: Thu, 30 May 2024 16:37:30 -0700 Subject: [PATCH 1/2] rename subject_attributes to subject_context for consistency --- eppo_client/client.py | 16 ++++++++-------- eppo_client/version.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/eppo_client/client.py b/eppo_client/client.py index b4f5790..5b37a31 100644 --- a/eppo_client/client.py +++ b/eppo_client/client.py @@ -225,7 +225,7 @@ def get_bandit_action( self, flag_key: str, subject_key: str, - subject_attributes: Attributes, + subject_context: Attributes, actions_with_contexts: List[ActionContext], default: str, ) -> BanditResult: @@ -244,7 +244,7 @@ def get_bandit_action( Args: flag_key (str): The feature flag key that contains the bandit as one of the variations. subject_key (str): The key identifying the subject. - subject_attributes (Attributes): The attributes of the subject. + subject_context (Attributes): The subject context actions_with_contexts (List[ActionContext]): The list of actions with their contexts. Returns: @@ -257,7 +257,7 @@ def get_bandit_action( return self.get_bandit_action_detail( flag_key, subject_key, - subject_attributes, + subject_context, actions_with_contexts, default, ) @@ -271,14 +271,14 @@ def get_bandit_action_detail( self, flag_key: str, subject_key: str, - subject_attributes: Attributes, + subject_context: Attributes, actions_with_contexts: List[ActionContext], default: str, ) -> BanditResult: # get experiment assignment # ignoring type because Dict[str, str] satisfies Dict[str, str | ...] but mypy does not understand variation = self.get_string_assignment( - flag_key, subject_key, subject_attributes.categorical_attributes, default # type: ignore + flag_key, subject_key, subject_context.categorical_attributes, default # type: ignore ) # if the variation is not the bandit key, then the subject is not allocated in the bandit @@ -297,7 +297,7 @@ def get_bandit_action_detail( evaluation = self.__bandit_evaluator.evaluate_bandit( flag_key, subject_key, - subject_attributes, + subject_context, actions_with_contexts, bandit_data.model_data, ) @@ -312,12 +312,12 @@ def get_bandit_action_detail( "modelVersion": bandit_data.model_version if evaluation else None, "timestamp": datetime.datetime.utcnow().isoformat(), "subjectNumericAttributes": ( - subject_attributes.numeric_attributes + subject_context.numeric_attributes if evaluation.subject_attributes else {} ), "subjectCategoricalAttributes": ( - subject_attributes.categorical_attributes + subject_context.categorical_attributes if evaluation.subject_attributes else {} ), diff --git a/eppo_client/version.py b/eppo_client/version.py index f5f41e5..d539d50 100644 --- a/eppo_client/version.py +++ b/eppo_client/version.py @@ -1 +1 @@ -__version__ = "3.1.0" +__version__ = "3.1.1" From 3aa442e4b5279cf4acdb47bf9272f3b1781d5be6 Mon Sep 17 00:00:00 2001 From: Sven Schmit Date: Thu, 30 May 2024 23:10:54 -0700 Subject: [PATCH 2/2] mypy ignore example/ --- pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fa7093a..8e5800b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,6 @@ [build-system] requires = ["setuptools>=42"] -build-backend = "setuptools.build_meta" \ No newline at end of file +build-backend = "setuptools.build_meta" + +[tool.mypy] +exclude = ['example/']