summaryrefslogtreecommitdiff
path: root/application.rb
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2019-07-05 08:26:18 +0000
committergebele <gebele@in-silico.ch>2019-07-05 08:26:18 +0000
commit86a45822c29cef7fb84871416427f96782e4ecf5 (patch)
tree19b732a99f23f93e33b2bab00d5466a8b91fc21a /application.rb
parentd68d732ca403f42caba01a96411c8a74b349defa (diff)
reorder validation statistics
Diffstat (limited to 'application.rb')
-rw-r--r--application.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/application.rb b/application.rb
index 060d163..db4c230 100644
--- a/application.rb
+++ b/application.rb
@@ -120,25 +120,26 @@ end
# download training dataset
get '/predict/dataset/:name' do
- response['Content-Type'] = "text/csv"
dataset = Dataset.find_by(:name=>params[:name])
csv = File.read dataset.source
+ name = params[:name] + ".csv"
t = Tempfile.new
t << csv
- name = params[:name] + ".csv"
+ t.rewind
+ response['Content-Type'] = "text/csv"
send_file t.path, :filename => name, :type => "text/csv", :disposition => "attachment"
end
# download batch predicton file
get '/predict/batch/download/?' do
task = Task.find params[:tid]
- prediction_dataset = Dataset.find task.dataset_id
- filename = prediction_dataset.name
- tempfile = Tempfile.new
- tempfile << prediction_dataset.to_prediction_csv
- tempfile.rewind
+ dataset = Dataset.find task.dataset_id
+ name = dataset.name + ".csv"
+ t = Tempfile.new
+ t << dataset.to_prediction_csv
+ t.rewind
response['Content-Type'] = "text/csv"
- send_file tempfile, :filename => "#{Time.now.strftime("%Y-%m-%d")}_lazar_batch_prediction_#{filename}.csv", :type => "text/csv", :disposition => "attachment"
+ send_file t.path, :filename => "#{Time.now.strftime("%Y-%m-%d")}_lazar_batch_prediction_#{name}", :type => "text/csv", :disposition => "attachment"
end
post '/predict/?' do