From 807b87cf18b42c055e62c91e31b05a728a7fdd42 Mon Sep 17 00:00:00 2001 From: gebele Date: Mon, 29 Jul 2019 14:53:44 +0000 Subject: optimize batch table size; mute task progress js functions --- application.rb | 10 ++++++---- public/javascripts/lazar-gui.js | 8 ++++---- views/batch.haml | 16 ++++++++-------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/application.rb b/application.rb index f5f3486..fa2a728 100644 --- a/application.rb +++ b/application.rb @@ -157,7 +157,9 @@ get '/predict/batch/download/?' do dataset = Dataset.find task.dataset_id name = dataset.name + ".csv" t = Tempfile.new - t << dataset.to_prediction_csv + # to_prediction_csv takes too much time; use task.csv instead which is the same + #t << dataset.to_prediction_csv + t << task.csv t.rewind response['Content-Type'] = "text/csv" send_file t.path, :filename => "#{Time.now.strftime("%Y-%m-%d")}_lazar_batch_prediction_#{name}", :type => "text/csv", :disposition => "attachment" @@ -253,21 +255,21 @@ get '/prediction/task/?' do cansmi = 0 header.each_with_index do |h,idx| cansmi = idx if h =~ /Canonical SMILES/ - string += "#{h}" + string += "#{h}" end string += "" string += "" csv[pageNumber].each_with_index do |line,idx| if idx == cansmi c = Compound.from_smiles line - string += "#{line}
" \ + string += "#{line}
" \ "" \ "#{embedded_svg(c.svg, title: "click for details")}" \ "" else - string += "#{line.numeric? && line.include?(".") ? line.to_f.signif(3) : line}" + string += "#{line.numeric? && line.include?(".") ? line.to_f.signif(3) : (line.nil? ? line : line.gsub(" ","
"))}" end end string += "" diff --git a/public/javascripts/lazar-gui.js b/public/javascripts/lazar-gui.js index f9d8255..214529b 100644 --- a/public/javascripts/lazar-gui.js +++ b/public/javascripts/lazar-gui.js @@ -178,7 +178,7 @@ function loadDetails(id, model_url) { var markers = []; -progress = function(value,id) { +/*progress = function(value,id) { var percent = Math.round(value); var bar = document.getElementById("bar_"+id); var est = document.getElementById("est_"+id); @@ -188,9 +188,9 @@ progress = function(value,id) { prog.style.display = "none"; est.style.display = "none"; }; -}; +};*/ -remaining = function(id,approximate) { +/*remaining = function(id,approximate) { var est = document.getElementById("est_"+id); var now = new Date().getTime(); var remain = approximate - now; @@ -202,7 +202,7 @@ remaining = function(id,approximate) { var newtime = minutes + "m " + seconds + "s "; } est.innerHTML = newtime; -}; +};*/ renderTask = function(task_uri,id) { var uri = task_uri; diff --git a/views/batch.haml b/views/batch.haml index f161125..efb9b71 100644 --- a/views/batch.haml +++ b/views/batch.haml @@ -18,17 +18,17 @@ // prepare variable values for javascript // increase timer interval for large datasets - ctimer = ((@compounds_size/1000) == 0 ? 1000 : ((@compounds_size/1000)*1000)) - - approx = {} - - sum_approx = 0 + //- approx = {} + //- sum_approx = 0 // process batch predictions - @models.each_with_index do |model,idx| - m = Model::Validation.find model - task = @tasks[idx].id - - tasktime = task.generation_time.to_i + //- tasktime = task.generation_time.to_i // assume single compound prediction time: classification=0.1s,regression=0.5s - - task_approx = m.classification? ? (tasktime*1000 + @compounds_size*100) : (tasktime*1000 + @compounds_size*500) - - approx[idx] = task_approx + sum_approx - - sum_approx += (m.classification? ? @compounds_size*100 : @compounds_size*500) + //- task_approx = m.classification? ? (tasktime*1000 + @compounds_size*100) : (tasktime*1000 + @compounds_size*500) + //- approx[idx] = task_approx + sum_approx + //- sum_approx += (m.classification? ? @compounds_size*100 : @compounds_size*500) #result.card.bg-light{:id=>idx} %div.card-body %div.row @@ -49,11 +49,11 @@ %img.h2{:src=>"/images/wait30trans.gif", :id=>"circle_#{idx}", :class=>"circle", :alt=>"wait", :style=>"display:none;"} :javascript $(document).ready(function() { - taskProgress('#{idx}','#{ctimer}','#{approx[idx]}','#{to("/prediction/task/?turi=#{task}")}'); + taskProgress('#{idx}','#{ctimer}','#{to("/prediction/task/?turi=#{task}")}'); }); #data-container.card.d-none.table-responsive{:id=>idx} :javascript - taskProgress = function(idx,timer,approximate,task_uri){ + taskProgress = function(idx,timer,task_uri){ // wait until previous task is completed if (idx > 0){ markers[idx] = setInterval(function(){ -- cgit v1.2.3