summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2019-08-02 10:57:06 +0000
committergebele <gebele@in-silico.ch>2019-08-02 10:57:06 +0000
commitb349cb51c4e46e1ae1bb309e9c589f1cff89e5af (patch)
tree397109ca0cddd78c60258ce2a85a89a67d1a4e77
parent62a7197574267404cc7034d78f552c4be0290a25 (diff)
optimize upload task with wait for dataset id
-rw-r--r--application.rb14
-rw-r--r--public/javascripts/lazar-gui.js4
-rw-r--r--views/batch.haml2
3 files changed, 10 insertions, 10 deletions
diff --git a/application.rb b/application.rb
index 1c738f1..965b7ec 100644
--- a/application.rb
+++ b/application.rb
@@ -180,14 +180,14 @@ post '/predict/?' do
uploadDataset = Task.run do
t = uploadTask
t.update_percent(1)
- $logger.debug "Processing '#{params[:fileselect][:filename]}'"
- @input = Dataset.from_csv_file File.join("tmp", params[:fileselect][:filename])
+ puts "Processing '#{params[:fileselect][:filename]}'"
+ input = Dataset.from_csv_file File.join("tmp", params[:fileselect][:filename])
+ t[:dataset_id] = input.id
t.update_percent(100)
t.save
end
@upid = uploadTask.id
- #TODO route for compound size
@compounds_size = 0 #@input.compounds.size
@models = params[:selection].keys
@tasks = []
@@ -201,12 +201,12 @@ post '/predict/?' do
prediction = {}
model = Model::Validation.find model_id
t.update_percent(10)
- input = Dataset.find_by(:source => "tmp/"+@filename)
- until input
+ until uploadTask.dataset_id
sleep 1
- input = Dataset.find_by(:source => "tmp/"+@filename)
+ uploadTask = Task.find @upid
end
- prediction_dataset = model.predict input
+ @input = Dataset.find uploadTask.dataset_id
+ prediction_dataset = model.predict @input
t.update_percent(70)
t[:dataset_id] = prediction_dataset.id
t.update_percent(75)
diff --git a/public/javascripts/lazar-gui.js b/public/javascripts/lazar-gui.js
index dcbc4c5..a672de4 100644
--- a/public/javascripts/lazar-gui.js
+++ b/public/javascripts/lazar-gui.js
@@ -210,7 +210,7 @@ uploadDataset = function(task_uri) {
aClient.get(uri, function(res) {
var response = JSON.parse(res);
if (response['percent'] == 100){
- window.clearInterval(uploadInterval);
+ clearInterval(uploadInterval);
var element = document.getElementById("uploadDataset");
element.parentNode.removeChild(element);
};
@@ -224,7 +224,7 @@ renderTask = function(task_uri,id) {
var response = JSON.parse(res);
//progress(response['percent'],id);
if (response['percent'] == 100){
- window.clearInterval(markers[id]);
+ clearInterval(markers[id]);
$("a#downbutton_"+id).removeClass("disabled");
$("a#detailsbutton_"+id).removeClass("disabled");
$("a#downbutton_"+id).removeClass("btn-outline-info");
diff --git a/views/batch.haml b/views/batch.haml
index 2e48ec0..ed69819 100644
--- a/views/batch.haml
+++ b/views/batch.haml
@@ -26,7 +26,7 @@
// prepare variable values for javascript
// increase timer interval for large datasets
- - ctimer = 1000#((@compounds_size/1000) == 0 ? 1000 : ((@compounds_size/1000)*1000))
+ - ctimer = 2000#((@compounds_size/1000) == 0 ? 1000 : ((@compounds_size/1000)*1000))
// process batch predictions
- @models.each_with_index do |model,idx|
- m = Model::Validation.find model