From f78d888a249303379c7934c83d5da11349a44b48 Mon Sep 17 00:00:00 2001 From: gebele Date: Fri, 13 Apr 2018 09:12:10 +0000 Subject: duplicate warning at bottom of batch result file --- application.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/application.rb b/application.rb index 8f78845..9c6f63e 100644 --- a/application.rb +++ b/application.rb @@ -164,7 +164,13 @@ get '/predict/csv/:task/:model/:filename/?' do else header = task.csv lines = [] - task.predictions[params[:model]].each_with_index{|p,idx| lines << "#{idx+1},#{Prediction.find(p).csv}"} + task.predictions[params[:model]].each_with_index do |p,idx| + if p.is_a? BSON::ObjectId + lines << "#{idx+1},#{Prediction.find(p).csv}" + else + lines << "#{idx+1},#{p}\n" + end + end csv = header + lines.join("") tempfile.write(csv) end @@ -336,6 +342,12 @@ post '/predict/?' do predictions["Cramer rules, with extensions"] = output["cramer_rules_extensions"].collect{|rule| rule != "nil" ? rule : "none"} predictions["compounds"] = @compounds.collect{|c| c.id} + if @dataset.warnings + @dataset.warnings.each do |warning| + w = warning.split(".").first + csv << w.sub(/,/," and")+"\n" + end + end # write csv t[:csv] = csv # write predictions @@ -345,6 +357,12 @@ post '/predict/?' do # save task # append predictions as last action otherwise they won't save # mongoid works with shallow copy via #dup + if @dataset.warnings + @dataset.warnings.each do |warning| + w = warning.split(".").first + @predictions["#{model}"] << w.sub(/,/," and") + end + end t[:predictions] = @predictions t.save end#models -- cgit v1.2.3