Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validation issue breaking L&G #54

Merged
merged 1 commit into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion static/js/banditLocal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ let bandit = new banditml.BanditAPI(
config = {
debugMode: true,
banditHostUrl: "http://localhost:8000/api/",
debugOptions: {forceVariantSlug: "bandit"}
debugOptions: {forceVariantSlug: "tf"}
}
);
10 changes: 7 additions & 3 deletions static/js/banditMl.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ banditml.BanditAPI = function (apiKey, recClassByExperimentId = {}, config = {})

// URLs & hosts
this.ipUrl = "https://api.ipify.org?format=json";

// special features known to backend
this.reservedFeatures = ["ipAddress"]
};

banditml.BanditAPI.prototype.addDecisionHandler = function (context, decision, experimentId) {
Expand Down Expand Up @@ -282,8 +285,8 @@ banditml.BanditAPI.prototype.validateAndFilterFeaturesInContext = function (cont
};
let filteredFeatures = {};
for (const featureName in context) {
if (featureName === "ipAddress") {
filteredFeatures.ipAddress = context.ipAddress;
if (self.reservedFeatures.includes(featureName)) {
filteredFeatures[featureName] = context[featureName];
continue;
}

Expand Down Expand Up @@ -328,7 +331,8 @@ banditml.BanditAPI.prototype.validateAndFilterFeaturesInContext = function (cont
this.logError(msg, {featureName: featureName}, e);
}
} else {
console.warn(`Feature ${featureName} is not recognized by the model. Please update your model to include this feature.`);
console.warn(`Feature ${featureName} is not defined in experiment context. Including it, but check experiment dash.`);
filteredFeatures[featureName] = context[featureName];
}
}
return filteredFeatures;
Expand Down
Loading