diff options
author | gebele <gebele@in-silico.ch> | 2019-08-09 12:28:19 +0000 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2019-08-09 12:28:19 +0000 |
commit | 74332693fed1d5ecb695dd6ae0c2fc611d14c4d7 (patch) | |
tree | fb5966afb8a65292b30dc5f65cd6408f7e82b560 | |
parent | 498ad82d2cc8582d3139bf69a0fe333d6b425668 (diff) |
do not delete batch tr_dataset if one of model tr_dataset;error message if dataset has no compounds
-rw-r--r-- | application.rb | 4 | ||||
-rw-r--r-- | helper.rb | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/application.rb b/application.rb index 246efe1..064c488 100644 --- a/application.rb +++ b/application.rb @@ -184,7 +184,7 @@ post '/predict/?' do raise "Wrong file extension for '#{params[:fileselect][:filename]}'. Please upload a CSV file." end @filename = params[:fileselect][:filename] - File.open('tmp/' + params[:fileselect][:filename], "w") do |f| + File.open('tmp/' + @filename, "w") do |f| f.write(params[:fileselect][:tempfile].read) end # check CSV structure by parsing and header check @@ -198,6 +198,7 @@ post '/predict/?' do unless params[:batchfile].blank? dataset = Dataset.from_csv_file File.join("tmp", params[:batchfile]) + raise "No compounds in Dataset. Please read the <a href='https://dg.in-silico.ch/predict/help' rel='external'> HELP </a> page." if dataset.compounds.size == 0 response['Content-Type'] = "application/json" return {:dataset_id => dataset.id.to_s, :models => params[:models]}.to_json end @@ -233,7 +234,6 @@ post '/predict/?' do maintask[:subTasks] = @tasks.collect{|t| t.id} maintask.save @pid = maintask.pid - File.delete File.join(dataset.source) response['Content-Type'] = "text/html" return haml :batch else @@ -31,10 +31,11 @@ helpers do predictionDataset = Dataset.find t.dataset_id if t.dataset_id if predictionDataset && idx == 0 trainingDataset = Dataset.find predictionDataset.source - source = trainingDataset.source - trainingDataset.delete - File.delete File.join(source) if File.exists? File.join(source) predictionDataset.delete + # delete training dataset unless it is one used for prediction models + models = Model::Validation.all + training_datasets = models.collect{|m| m.training_dataset.id.to_s} + trainingDataset.delete unless training_datasets.include?(trainingDataset.id.to_s) elsif predictionDataset predictionDataset.delete end |