Skip to content

Commit

Permalink
refactor(python): split into multiple files
Browse files Browse the repository at this point in the history
The one file was growing too big. Split it into multiple files for
easier maintenance.
  • Loading branch information
rasendubi committed Aug 21, 2024
1 parent b0c4a8c commit 676d644
Show file tree
Hide file tree
Showing 7 changed files with 548 additions and 529 deletions.
7 changes: 3 additions & 4 deletions eppo_core/src/context_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ where
acc.numeric.insert(key.to_owned(), value);
}
AttributeValue::Boolean(value) => {
// TBD: shall we ignore boolean attributes instead?
//
// One argument for including it here is that this basically guarantees that
// assignment evaluation inside bandit evaluation works the same way as if
// `get_assignment()` was called with generic `Attributes`.
//
// We can go a step further and remove `AttributeValue::Boolean` altogether,
// forcing it to be converted to a string before any evaluation.
// We can go a step further and remove `AttributeValue::Boolean` altogether
// (from `eppo_core`), forcing it to be converted to a string before any
// evaluation.
acc.categorical.insert(key.to_owned(), value.to_string());
}
AttributeValue::Null => {
Expand Down
1 change: 1 addition & 0 deletions eppo_core/src/pyo3.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Helpers for Python SDK implementation.
use pyo3::prelude::*;

/// Similar to [`pyo3::ToPyObject`] but allows the conversion to fail.
Expand Down
20 changes: 20 additions & 0 deletions python-sdk/src/assignment_logger.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use pyo3::prelude::*;
use pyo3::types::PyDict;

#[derive(Debug, Clone)]
#[pyclass(frozen, subclass, module = "eppo_client")]
pub struct AssignmentLogger {}

#[pymethods]
impl AssignmentLogger {
#[new]
fn new() -> AssignmentLogger {
AssignmentLogger {}
}

#[allow(unused_variables)]
fn log_assignment(slf: Bound<Self>, event: Bound<PyDict>) {}

#[allow(unused_variables)]
fn log_bandit_action(slf: Bound<Self>, event: Bound<PyDict>) {}
}
Loading

0 comments on commit 676d644

Please sign in to comment.