From 52afe930d54e55d3911532b15bd70b1da8fa77ab Mon Sep 17 00:00:00 2001 From: Oleksii Shmalko Date: Fri, 19 Jul 2024 17:02:27 +0300 Subject: [PATCH] feat: update bandit flow to return bandit variation if actions are empty --- eppo_core/src/bandits/eval.rs | 12 ++++-------- package.json | 2 +- ruby-sdk/Rakefile | 15 --------------- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/eppo_core/src/bandits/eval.rs b/eppo_core/src/bandits/eval.rs index 30b23d7b..558e3ea7 100644 --- a/eppo_core/src/bandits/eval.rs +++ b/eppo_core/src/bandits/eval.rs @@ -98,13 +98,11 @@ impl Configuration { // // This should normally never happen as it means that there's a mismatch between the // general UFC config and bandits config. - // - // Abort evaluation and return default variant, ignoring `assignment.event` logging. log::warn!(target: "eppo", bandit_key; "unable to find bandit configuration"); return BanditResult { - variation: default_variation.to_owned(), + variation, action: None, - assignment_event: None, + assignment_event: assignment.event, bandit_event: None, }; }; @@ -116,12 +114,10 @@ impl Configuration { else { // We've evaluated a flag but now bandit evaluation failed. (Likely to user supplying // empty actions, or NaN attributes.) - // - // Abort evaluation and return default variant, ignoring `assignment.event` logging. return BanditResult { - variation: default_variation.to_owned(), + variation, action: None, - assignment_event: None, + assignment_event: assignment.event, bandit_event: None, }; }; diff --git a/package.json b/package.json index 79d9936d..8cb131b2 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "scripts": { "test": "npm run with-server 'npm-run-all test:*'", "test:rust": "cargo test", - "test:ruby": "cd ruby-sdk && bundle exec rspec", + "test:ruby": "cd ruby-sdk && bundle exec rake test", "with-server": "start-server-and-test start-mock-server http://127.0.0.1:8378", "start-mock-server": "npm start --prefix ./mock-server" }, diff --git a/ruby-sdk/Rakefile b/ruby-sdk/Rakefile index 745c2c50..aaf945ce 100644 --- a/ruby-sdk/Rakefile +++ b/ruby-sdk/Rakefile @@ -43,21 +43,6 @@ task :clean do system 'rm *.gem' end -test_data_dir = 'spec/test-data/' -temp_dir = "#{test_data_dir}temp/" -git_data_dir = "#{temp_dir}sdk-test-data/" -branch_name = 'main' -github_repo_link = 'https://github.com/Eppo-exp/sdk-test-data.git' -file 'test-data' do - rm_rf test_data_dir - mkdir_p temp_dir - sh "git clone -b #{branch_name} --depth 1 --single-branch "\ - "#{github_repo_link} #{git_data_dir}" - cp "#{git_data_dir}rac-experiments-v3.json", test_data_dir - cp_r "#{git_data_dir}assignment-v2", test_data_dir - rm_rf temp_dir -end - RSpec::Core::RakeTask.new(:test) do |task| root_dir = Rake.application.original_dir task.pattern = "#{root_dir}/spec/*_spec.rb"