summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2017-03-16 13:20:32 +0000
committergebele <gebele@in-silico.ch>2017-03-16 13:20:32 +0000
commit3f4d54a0303e433b3634277a3a6c76ec74b4d304 (patch)
tree86d19bc13f0c531d2440b2c5c7f56f21e3e8a37d
parent46980e6c9a34be5c9f61c35350faea7cc370e1ec (diff)
delete models without drop the whole db;work with central db
-rw-r--r--create_prediction_models.rb42
1 files 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)}`