Skip to content

Commit

Permalink
Merge pull request #50 from econti/do-not-use-populate
Browse files Browse the repository at this point in the history
Log result of filterRecs, toss a warning if populateDecisions modifies decisions
  • Loading branch information
lgvital authored May 29, 2020
2 parents 921b313 + d79e614 commit 2269aa8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions static/js/banditLocal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
// product set case
// let experimentId = "18c08829-e49e-421f-a13b-77e7d6d0221b";
// product set multi-dynamic case
let experimentId = "7703f35c-f0a5-42a3-b0d9-d29c3952bd97";
let experimentId = "fce763c5-eaf6-4b4d-ae42-47d62ecf04ab";
// category case
// let experimentId = "59204365-5e27-4c8c-a21b-e1a81d373979";
function getSessionIdCustom () {
return "1235"
}
let bandit = new banditml.BanditAPI("c52e1439-77bc-3cfd-b422-6a4d9a1e2c8c", {[experimentId]: "recsCategory"}, {debugMode: true, debugOptions: {forceVariantSlug: "variant-74"}, banditHostUrl: "http://localhost:8000/api/", getSessionId: getSessionIdCustom});
let bandit = new banditml.BanditAPI("c52e1439-77bc-3cfd-b422-6a4d9a1e2c8c", {[experimentId]: "recsCategory"}, {debugMode: true, debugOptions: {forceVariantSlug: "control"}, banditHostUrl: "http://localhost:8000/api/", getSessionId: getSessionIdCustom});
11 changes: 7 additions & 4 deletions static/js/banditMl.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ banditml.BanditAPI.prototype.setRecs = async function (
}
}
if (self.config.debugMode) {
console.log("After filtering, the following recs will be shown:");
console.log("After filtering, the following recs will be shown and logged:");
console.log(decisionIds);
}
if (populateDecisions) {
Expand All @@ -469,9 +469,12 @@ banditml.BanditAPI.prototype.setRecs = async function (
let result = populateDecisions(decisionIds);
if (result) {
if (result.then) {
decisionIds = await result;
} else {
decisionIds = result;
result = await result;
}
if (self.config.debugMode) {
if (result !== decisionIds) {
console.warn(`populateDecisions function is returning a different result (${result}) than filterRecs (${decisionIds}). Ensure that populateDecisions is not modifying decisions.`);
}
}
}
}
Expand Down
Loading

0 comments on commit 2269aa8

Please sign in to comment.