From 3f4d54a0303e433b3634277a3a6c76ec74b4d304 Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 16 Mar 2017 13:20:32 +0000 Subject: delete models without drop the whole db;work with central db --- create_prediction_models.rb | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/create_prediction_models.rb b/create_prediction_models.rb index 9c3995f..d58728e 100644 --- a/create_prediction_models.rb +++ b/create_prediction_models.rb @@ -2,24 +2,52 @@ ENV["LAZAR_ENV"] = "production" require_relative '../lazar/lib/lazar' #require 'lazar' include OpenTox -#$mongo.database.drop -#$gridfs = $mongo.database.fs # recreate GridFS indexes +$mongo.database.drop +$gridfs = $mongo.database.fs # recreate GridFS indexes -=begin +@models = OpenTox::Model::Validation.all + +def delete_models type + case type + when "classification" + models = @models.delete_if{|m| !m.classification?} + when "regression" + models = @models.delete_if{|m| !m.regression?} + else + puts "Unknown model type #{type}" + exit + end + models.each do |m| + m.training_dataset.delete + m.crossvalidations.each{|cv| cv.delete} + m.model.delete + m.delete + end +end + +puts CENTRAL_MONGO_IP.blank? ? "Use local mongodb on port: 127.0.0.1" : "Use central mongodb on port: #{CENTRAL_MONGO_IP}" + +#=begin # classification models +#delete_models "classification" Dir["classification/*csv"].each do |file| unless file.match(/hamster/) + puts "### #{file} ###\n" Model::Validation.from_csv_file file end + puts "### done: #{file} ###\n" end -=end +#=end #=begin # regression models +#delete_models "regression" Dir["regression/*log10.csv"].each do |file| unless file.match(/fathead/)#until dublicates not cleared + puts "### #{file} ###\n" Model::Validation.from_csv_file file end + puts "### done: #{file} ###\n" end #=end @@ -64,11 +92,11 @@ feature_categories.each do |category| end =end -# save local dump but git ignored -`mongodump -h 127.0.0.1 -d production` +# store local dump but git ignored +`mongodump -h #{CENTRAL_MONGO_IP.blank? ? "127.0.0.1" : CENTRAL_MONGO_IP} -d production` # build reports and users dump eval File.read('./lazar_validation_reports.rb') # restore -#`mongorestore --host 127.0.0.1` +#`mongorestore --host #{(CENTRAL_MONGO_IP.blank? ? "127.0.0.1" : CENTRAL_MONGO_IP)}` -- cgit v1.2.3