Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:PredictionIO/PredictionIO into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
Donald Szeto committed Oct 5, 2013
2 parents 77e9f68 + 23f367c commit a480e79
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 68 deletions.
42 changes: 27 additions & 15 deletions servers/admin/app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1241,25 +1241,37 @@ object Application extends Controller {
}

// Apply the selected params to the algo
def algoAutotuningSelect(app_id: String, engine_id: String, algo_id: String, algoautotune_id: String) = withUser { user => implicit request =>
def algoAutotuningSelect(app_id: String, engine_id: String, algo_id: String) = withUser { user => implicit request =>

// Apply params of algoautotune_id to algo_id
// Apply POST request params of tuned_algo_id to algo_id
// update the status of algo_id from 'tuning' or 'tuned' to 'ready'

val orgAlgo = algos.get(algo_id.toInt)
val tunedAlgo = algos.get(algoautotune_id.toInt)
val form = Form("tuned_algo_id" -> number)

if ((orgAlgo == None) || (tunedAlgo == None)) {
NotFound(toJson(Map("message" -> toJson("Invalid app id, engine id or algo id."))))
} else {
val tunedAlgoParams = tunedAlgo.get.params ++ Map("tune" -> "manual")
algos.update(orgAlgo.get.copy(
params = tunedAlgoParams,
status = "ready"
))

Ok
}
form.bindFromRequest.fold(
formWithError => {
val msg = formWithError.errors(0).message // extract 1st error message only
BadRequest(toJson(Map("message" -> toJson(msg))))
},
formData => {
val tunedAlgoid = formData

val orgAlgo = algos.get(algo_id.toInt)
val tunedAlgo = algos.get(tunedAlgoid)

if ((orgAlgo == None) || (tunedAlgo == None)) {
NotFound(toJson(Map("message" -> toJson("Invalid app id, engine id or algo id."))))
} else {
val tunedAlgoParams = tunedAlgo.get.params ++ Map("tune" -> "manual")
algos.update(orgAlgo.get.copy(
params = tunedAlgoParams,
status = "ready"
))

Ok
}
}
)
}


Expand Down
72 changes: 42 additions & 30 deletions servers/admin/conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ GET / controllers.Application.redirectToWeb
GET /web controllers.Application.redirectToWeb
GET /web/ controllers.Application.showWeb
GET /web/assets/*file controllers.Assets.at(path="/public", file)

### During development, use enginebase controller instead to avoid cache problems
# TODO: remove these new routes when work on PDIO-235
GET /web/enginebase/*file controllers.Assets.at(path="/enginebase", file)
# GET /web/enginebase/*file controllers.Application.enginebase(file)

# TODO: use these new routes when work on PDIO-235
#GET /engineinfos/:engineinfoid/:filename controllers.engineinfo.getFile(engineinfoid, filename)
#GET /algoinfos/:algoinfoid/:filename controllers.algoinfo.getFile(algoinfoid, filename)


POST /signin controllers.Application.signin
POST /signout controllers.Application.signout
Expand All @@ -18,53 +24,59 @@ POST /signout controllers.Application.signout
GET /auth controllers.Application.getAuth

# An App
GET /app_list controllers.Application.getApplist
GET /app/:id controllers.Application.getApp(id)
POST /app controllers.Application.createApp
DELETE /app/:id controllers.Application.removeApp(id)
#PUT /app/:id controllers.Application.updateApp(id)
GET /app_details/:id controllers.Application.getAppDetails(id)
GET /app_engine_list/:id controllers.Application.getAppEnginelist(id)
POST /app/erasedata/:id controllers.Application.eraseAppData(id)
GET /apps controllers.Application.getApplist
GET /apps/:id controllers.Application.getApp(id)
POST /apps controllers.Application.createApp
DELETE /apps/:id controllers.Application.removeApp(id)
#PUT /apps/:id controllers.Application.updateApp(id)
GET /apps/:id/details controllers.Application.getAppDetails(id)
GET /apps/:id/engines controllers.Application.getAppEnginelist(id)
POST /apps/:id/erase_data controllers.Application.eraseAppData(id)

# System Level
GET /enginetype_list controllers.Application.getEngineTypeList
GET /enginetype_algolist/:id controllers.Application.getEngineTypeAlgoList(id)
GET /enginetype_metricstype_list/:id controllers.Application.getEngineTypeMetricsTypeList(id)
GET /engineinfos controllers.Application.getEngineTypeList
GET /engineinfos/:id/algoinfos controllers.Application.getEngineTypeAlgoList(id)
GET /engineinfos/:id/metricinfos controllers.Application.getEngineTypeMetricsTypeList(id)

# An Engine of an App
GET /app/:app_id/engine/:id controllers.Application.getEngine(app_id, id)
POST /app/:app_id/engine controllers.Application.createEngine(app_id)
DELETE /app/:app_id/engine/:engine_id controllers.Application.removeEngine(app_id, engine_id)
GET /app/:app_id/engine/:engine_id/algo_available_list controllers.Application.getAvailableAlgoList(app_id, engine_id)
GET /app/:app_id/engine/:engine_id/algo_available/:id controllers.Application.getAvailableAlgo(app_id, engine_id, id)
POST /app/:app_id/engine/:engine_id/algo_available controllers.Application.createAvailableAlgo(app_id, engine_id)
DELETE /app/:app_id/engine/:engine_id/algo_available/:id controllers.Application.removeAvailableAlgo(app_id: Int, engine_id: Int, id: Int)
GET /app/:app_id/engine/:engine_id/algoautotuning_report/:algo_id controllers.Application.getAlgoAutotuningReport(app_id, engine_id, algo_id)

POST /app/:app_id/engine/:engine_id/algo/:algo_id/algoautotuning_select/:algoautotune_id controllers.Application.algoAutotuningSelect(app_id, engine_id, algo_id, algoautotune_id)
GET /apps/:app_id/engines/:id controllers.Application.getEngine(app_id, id)
POST /apps/:app_id/engines controllers.Application.createEngine(app_id)
DELETE /apps/:app_id/engines/:id controllers.Application.removeEngine(app_id, id)

GET /apps/:app_id/engines/:engine_id/algos_available controllers.Application.getAvailableAlgoList(app_id, engine_id)
GET /apps/:app_id/engines/:engine_id/algos_available/:id controllers.Application.getAvailableAlgo(app_id, engine_id, id)
POST /apps/:app_id/engines/:engine_id/algos_available controllers.Application.createAvailableAlgo(app_id, engine_id)
DELETE /apps/:app_id/engines/:engine_id/algos_available/:id controllers.Application.removeAvailableAlgo(app_id: Int, engine_id: Int, id: Int)

GET /app/:app_id/engine/:engine_id/algo_deployed controllers.Application.getDeployedAlgo(app_id, engine_id)
GET /apps/:app_id/engines/:engine_id/algos_deployed controllers.Application.getDeployedAlgo(app_id, engine_id)
POST /apps/:app_id/engines/:engine_id/algos_deploy controllers.Application.algoDeploy(app_id, engine_id)
POST /apps/:app_id/engines/:engine_id/algos_undeploy controllers.Application.algoUndeploy(app_id, engine_id)
POST /apps/:app_id/engines/:engine_id/algos_trainnow controllers.Application.algoTrainNow(app_id, engine_id)

GET /app/:app_id/engine/:engine_id/simeval_list controllers.Application.getSimEvalList(app_id, engine_id)
POST /app/:app_id/engine/:engine_id/simeval controllers.Application.createSimEval(app_id, engine_id)
DELETE /app/:app_id/engine/:engine_id/simeval/:id controllers.Application.removeSimEval(app_id: Int, engine_id: Int, id: Int)
GET /app/:app_id/engine/:engine_id/simeval_report/:id controllers.Application.getSimEvalReport(app_id, engine_id, id)

POST /app/:app_id/engine/:engine_id/algo_deploy controllers.Application.algoDeploy(app_id, engine_id)
POST /app/:app_id/engine/:engine_id/algo_undeploy controllers.Application.algoUndeploy(app_id, engine_id)
POST /app/:app_id/engine/:engine_id/algo_trainnow controllers.Application.algoTrainNow(app_id, engine_id)
GET /apps/:app_id/engines/:engine_id/simevals controllers.Application.getSimEvalList(app_id, engine_id)
POST /apps/:app_id/engines/:engine_id/simevals controllers.Application.createSimEval(app_id, engine_id)
DELETE /apps/:app_id/engines/:engine_id/simevals/:id controllers.Application.removeSimEval(app_id: Int, engine_id: Int, id: Int)
GET /apps/:app_id/engines/:engine_id/simevals/:id/report controllers.Application.getSimEvalReport(app_id, engine_id, id)

GET /apps/:app_id/engines/:engine_id/algos_available/:algo_id/autotune_report controllers.Application.getAlgoAutotuningReport(app_id, engine_id, algo_id)
POST /apps/:app_id/engines/:engine_id/algos_available/:algo_id/autotune_apply controllers.Application.algoAutotuningSelect(app_id, engine_id, algo_id)

# Engine Module
#GET /apps/:app_id/engines/:engine_id/settings controllers.Application.getEngineSettings(app_id, engine_id) # TODO: use this when work on PDIO-227
#PUT /apps/:app_id/engines/:engine_id/settings controllers.Application.updateEngineSettings(app_id, engine_id) # TODO: use this when work on PDIO-227

# TODO remove the following when work on PDIO-227
GET /modules/itemrec/settings/app/:app_id/engine/:engine_id controllers.Itemrec.Engine.getSettings(app_id, engine_id)
PUT /modules/itemrec/settings/app/:app_id/engine/:engine_id controllers.Itemrec.Engine.updateSettings(app_id, engine_id)

GET /modules/itemsim/settings/app/:app_id/engine/:engine_id controllers.Itemsim.Engine.getSettings(app_id, engine_id)
PUT /modules/itemsim/settings/app/:app_id/engine/:engine_id controllers.Itemsim.Engine.updateSettings(app_id, engine_id)

# Algo Module
#GET /apps/:app_id/engines/:engine_id/algos/:algo_id/settings controllers.Application.getAlgoSettings(app_id, engine_id, algo_id) # TODO use this when work on PDIO-227
#PUT /apps/:app_id/engines/:engine_id/algos/:algo_id/settings controllers.Application.updateAlgoSettings(app_id, engine_id, algo_id) # TODO use this when work on PDIO-227

# TODO remove the following when work on PDIO-227
GET /modules/itemrec/settings/app/:app_id/engine/:engine_id/pdio-knnitembased/:algo_id controllers.Itemrec.PdioKnnItemBased.getSettings(app_id, engine_id, algo_id)
PUT /modules/itemrec/settings/app/:app_id/engine/:engine_id/pdio-knnitembased/:algo_id controllers.Itemrec.PdioKnnItemBased.updateSettings(app_id, engine_id, algo_id)

Expand Down
62 changes: 39 additions & 23 deletions servers/admin/public/javascripts/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,11 @@ var AppsDashboardView = Backbone.View.extend({
});

var AppModel = Backbone.Model.extend({
urlRoot: getAPIUrl('app')
urlRoot: getAPIUrl('apps')
});
var AppListModel = Backbone.Collection.extend({
model: AppModel,
url: getAPIUrl('app_list')
url: getAPIUrl('apps')
});
var AppListView = Backbone.View.extend({
initialize: function(){
Expand Down Expand Up @@ -475,7 +475,7 @@ var AppView = Backbone.View.extend({
buttons: {
"Erase All Data": function() {
var erasingInfo = notifyInfo('Erasing All Application Data...','', {positionClass: 'toast-bottom-right', fadeOut: 1});
$.post(getAPIUrl("app/erasedata/"+self.id), function() {
$.post(getAPIUrl("apps/"+self.id+"/erase_data"), function() {
self.appDetailsView.model.fetch(); // refresh data
notifyClear(erasingInfo);
notifyInfo('Data Erased.','', {positionClass: 'toast-bottom-right', timeOut: 2800});
Expand Down Expand Up @@ -524,7 +524,9 @@ var AppView = Backbone.View.extend({
});

var AppDetailsModel = Backbone.Model.extend({
urlRoot: getAPIUrl('app_details')
url: function() {
return getAPIUrl('apps/' + this.id + "/details");
}
});
var AppDetailsView = Backbone.View.extend({
/*
Expand Down Expand Up @@ -554,7 +556,9 @@ var AppDetailsView = Backbone.View.extend({


var AppEnginelistModel = Backbone.Model.extend({
urlRoot: getAPIUrl('app_engine_list')
url: function() {
return getAPIUrl('apps/' + this.id + '/engines');
}
});
var AppEnginelistView = Backbone.View.extend({
/*
Expand Down Expand Up @@ -812,12 +816,12 @@ var onDataSplitPercentChange = function(e){


var EngineTypeListModel = Backbone.Model.extend({
urlRoot: getAPIUrl('enginetype_list')
urlRoot: getAPIUrl('engineinfos')
});
var EngineModel = Backbone.Model.extend({
/* Required param: app_id */
urlRoot: function(){
return getAPIUrl("app/" +this.get("app_id") + "/engine");
return getAPIUrl("apps/" +this.get("app_id") + "/engines");
}
});
var AddEngineView = Backbone.View.extend({
Expand Down Expand Up @@ -937,7 +941,7 @@ var EngineAlgorithmsView = Backbone.View.extend({
/* Required param: app_id, engine_id */
var DeployedAlgoModel = Backbone.Model.extend({
urlRoot: function() {
var path ='app/' + this.get('app_id') + '/engine/' + this.get('engine_id') +'/algo_deployed';
var path ='apps/' + this.get('app_id') + '/engines/' + this.get('engine_id') +'/algos_deployed';
return getAPIUrl(path);
}
});
Expand All @@ -962,7 +966,7 @@ var EngineAlgorithmsDeployedAlgoView = Backbone.View.extend({
},
undeploy: function() {
var self = this;
var path ='app/' + this.app_id + '/engine/' + this.engine_id +'/algo_undeploy';
var path ='apps/' + this.app_id + '/engines/' + this.engine_id +'/algos_undeploy';
$.post(getAPIUrl(path), function() {
var app_id = self.model.get('app_id');
var engine_id = self.model.get('engine_id');
Expand All @@ -976,7 +980,7 @@ var EngineAlgorithmsDeployedAlgoView = Backbone.View.extend({
},
trainnow: function() {
var self = this;
var path ='app/' + this.app_id + '/engine/' + this.engine_id +'/algo_trainnow';
var path ='apps/' + this.app_id + '/engines/' + this.engine_id +'/algos_trainnow';
var info = notifyInfo('Requesting to train data model immediately...', '', {positionClass: 'toast-bottom-right', fadeOut: 1});
$.post(getAPIUrl(path), function(res) {
notifyClear(info);
Expand All @@ -1002,15 +1006,15 @@ var EngineAlgorithmsDeployedAlgoView = Backbone.View.extend({
/* Required param: app_id, engine_id */
var AvailableAlgoModel = Backbone.Model.extend({
urlRoot: function() {
var path ='app/' + this.get('app_id') + '/engine/' + this.get('engine_id') +'/algo_available';
var path ='apps/' + this.get('app_id') + '/engines/' + this.get('engine_id') +'/algos_available';
return getAPIUrl(path);
}
});
/* Required param: app_id, engine_id */
var AvailableAlgoListCollection = Backbone.Collection.extend({
model: AvailableAlgoModel,
initialize: function(models, options) {
this.url = getAPIUrl('app/' + options.app_id + '/engine/' + options.engine_id +'/algo_available_list');
this.url = getAPIUrl('apps/' + options.app_id + '/engines/' + options.engine_id +'/algos_available');
}
});
var EngineAlgorithmsAvailableAlgoListView = Backbone.View.extend({
Expand Down Expand Up @@ -1065,7 +1069,7 @@ var EngineAlgorithmsAvailableAlgoListView = Backbone.View.extend({
},
deploy: function(algo_id_list) { // common func for deploying single/multiple algo(s)
var self = this;
var path ='app/' + this.app_id + '/engine/' + this.engine_id +'/algo_deploy';
var path ='apps/' + this.app_id + '/engines/' + this.engine_id +'/algos_deploy';
$.ajax({
type: "POST",
url: getAPIUrl(path),
Expand Down Expand Up @@ -1145,15 +1149,15 @@ var EngineAlgorithmsAvailableAlgoView = Backbone.View.extend({
/* Required param: app_id, engine_id */
var SimEvalModel = Backbone.Model.extend({
urlRoot: function() {
var path ='app/' + this.get('app_id') + '/engine/' + this.get('engine_id') +'/simeval';
var path ='apps/' + this.get('app_id') + '/engines/' + this.get('engine_id') +'/simevals';
return getAPIUrl(path);
}
});
/* Required param: app_id, engine_id */
var SimEvalListCollection = Backbone.Collection.extend({
model: SimEvalModel,
initialize: function(models, options) {
this.url = getAPIUrl('app/' + options.app_id + '/engine/' + options.engine_id +'/simeval_list');
this.url = getAPIUrl('apps/' + options.app_id + '/engines/' + options.engine_id +'/simevals');
}
});
var EngineAlgorithmsSimEvalListView = Backbone.View.extend({
Expand Down Expand Up @@ -1231,7 +1235,9 @@ var EngineAlgorithmsSimEvalView = Backbone.View.extend({


var EnginetypeAlgorithmListModel = Backbone.Model.extend({
urlRoot: getAPIUrl('enginetype_algolist')
url: function() {
return getAPIUrl('engineinfos/' + this.id + '/algoinfos');
}
});
var EngineAddAlgorithmView = Backbone.View.extend({
initialize : function() {
Expand Down Expand Up @@ -1276,7 +1282,8 @@ var EngineAddAlgorithmView = Backbone.View.extend({

var EngineAlgoAutotuningReportModel = Backbone.Model.extend({
initialize: function(model, options) {
this.urlRoot = getAPIUrl('app/' + options.app_id + '/engine/' + options.engine_id +'/algoautotuning_report');
//this.urlRoot = getAPIUrl('apps/' + options.app_id + '/engines/' + options.engine_id +'/algoautotuning_report'); # TODO: remove
this.url = getAPIUrl('apps/' + options.app_id + '/engines/' + options.engine_id +'/algos_available/' + this.id + '/autotune_report');
}
});
var EngineAlgoAutotuningReportView = Backbone.View.extend({
Expand All @@ -1300,10 +1307,16 @@ var EngineAlgoAutotuningReportView = Backbone.View.extend({
return this;
},
selectAutotune: function(e) {
var algoautotune_id = $(e.target).data('autotuneid');
var path ='app/' + this.app_id + '/engine/' + this.engine_id +'/algo/' + this.algo_id + '/algoautotuning_select/' + algoautotune_id;
$.post(getAPIUrl(path), function() {
window.location.hash = 'engineTabAlgorithms';
var tuned_algo_id = $(e.target).data('autotuneid');
var path ='apps/' + this.app_id + '/engines/' + this.engine_id +'/algos_available/' + this.algo_id + '/autotune_apply';
$.ajax({
type: "POST",
url: getAPIUrl(path),
data: JSON.stringify({tuned_algo_id: tuned_algo_id}),
contentType: "application/json; charset=utf-8",
success: function() {
window.location.hash = 'engineTabAlgorithms';
}
}).error(function(res) {
alert("An error has occured:" + res.status);
});
Expand All @@ -1313,7 +1326,8 @@ var EngineAlgoAutotuningReportView = Backbone.View.extend({

var EngineSimEvalReportModel = Backbone.Model.extend({
initialize: function(model, options) {
this.urlRoot = getAPIUrl('app/' + options.app_id + '/engine/' + options.engine_id +'/simeval_report');
//this.urlRoot = getAPIUrl('app/' + options.app_id + '/engine/' + options.engine_id +'/simeval_report');
this.url = getAPIUrl('apps/' + options.app_id + '/engines/' + options.engine_id +'/simevals/' + this.id + '/report');
}
});
/* Required Param: id (simulated eval report id) */
Expand All @@ -1339,7 +1353,9 @@ var EngineSimEvalReportView = Backbone.View.extend({


var EnginetypeMetricsTypeListModel = Backbone.Model.extend({
urlRoot: getAPIUrl('enginetype_metricstype_list')
url: function() {
return getAPIUrl('engineinfos/' + this.id + "/metricinfos");
}
});
/* Required Param: algo_id_list (algo ids to be evaluated) */
var EngineSimEvalSettingsView = Backbone.View.extend({
Expand Down

0 comments on commit a480e79

Please sign in to comment.