summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormr <mr@mrautenberg.de>2011-06-15 13:12:34 +0200
committermr <mr@mrautenberg.de>2011-06-15 13:12:34 +0200
commit68f0e8a9b4ab9c6eda1da21423bda0186cfd01c6 (patch)
treead5ad32312e4132976b30a3985a8f62135fe3463
parent916f715ee52049a0968bc04df5aa6ca0a9a6881d (diff)
parent59e1a2406354ce8a7e2b1a78f03d6ecaf6dbb297 (diff)
Merge branch 'hotfix/qmrf_mysqlite'
-rwxr-xr-xreach_reports/reach_application.rb14
-rwxr-xr-xreach_reports/reach_persistance.rb14
-rwxr-xr-xreach_reports/reach_service.rb20
-rwxr-xr-xreport/report_content.rb3
-rw-r--r--report/statistical_test.rb19
5 files changed, 51 insertions, 19 deletions
diff --git a/reach_reports/reach_application.rb b/reach_reports/reach_application.rb
index cd0695c..9b45e8b 100755
--- a/reach_reports/reach_application.rb
+++ b/reach_reports/reach_application.rb
@@ -5,6 +5,20 @@ end
QMRF_EDITOR_URI = "http://ortona.informatik.uni-freiburg.de/qmrfedit2/OT_QMRFEditor.jnlp"
+# hack for as long as mysql lite is used
+def mysql_lite_retry( n_times=15 )
+ n_times.times do
+ begin
+ yield
+ return
+ rescue => ex
+ LOGGER.warn "datamapper error, wait and retry : "+ex.message
+ sleep(1+rand(3)) # wait 1-3 seconds
+ end
+ end
+ yield # try a last time
+end
+
require 'reach_reports/reach_persistance.rb'
require 'reach_reports/reach_service.rb'
diff --git a/reach_reports/reach_persistance.rb b/reach_reports/reach_persistance.rb
index b90778b..2dd687a 100755
--- a/reach_reports/reach_persistance.rb
+++ b/reach_reports/reach_persistance.rb
@@ -1202,11 +1202,13 @@ module ReachReports
# end
# end
- [ QsarSoftware, QsarIdentifier, QmrfAuthor, ModelAuthor, Reference, QsarGeneralInformation, ModelEndpoint, QsarEndpoint, AlgorithmExplicit,
- AlgorithmsDescriptor, DescriptorsGenerationSoftware, QsarAlgorithm, AppDomainSoftware, QsarApplicabilityDomain, TrainingSetData,
- QsarRobustness, ValidationSetData, QsarPredictivity, QsarInterpretation, Bibliography, AttachmentTrainingData, AttachmentValidationData,
- AttachmentDocument, QsarMiscellaneous, QmrfSummary, QmrfReport ].each do |model|
- model.auto_upgrade!
- model.raise_on_save_failure = true
+ mysql_lite_retry do
+ [ QsarSoftware, QsarIdentifier, QmrfAuthor, ModelAuthor, Reference, QsarGeneralInformation, ModelEndpoint, QsarEndpoint, AlgorithmExplicit,
+ AlgorithmsDescriptor, DescriptorsGenerationSoftware, QsarAlgorithm, AppDomainSoftware, QsarApplicabilityDomain, TrainingSetData,
+ QsarRobustness, ValidationSetData, QsarPredictivity, QsarInterpretation, Bibliography, AttachmentTrainingData, AttachmentValidationData,
+ AttachmentDocument, QsarMiscellaneous, QmrfSummary, QmrfReport ].each do |model|
+ model.auto_upgrade!
+ model.raise_on_save_failure = true
+ end
end
end \ No newline at end of file
diff --git a/reach_reports/reach_service.rb b/reach_reports/reach_service.rb
index 0cf4172..1ec48e8 100755
--- a/reach_reports/reach_service.rb
+++ b/reach_reports/reach_service.rb
@@ -277,7 +277,9 @@ module ReachReports
end
task.progress(90) if task
- r.save
+ mysql_lite_retry do
+ r.save
+ end
task.progress(100) if task
end
@@ -292,14 +294,16 @@ module ReachReports
# end
def self.get_report(type, id)
-
- case type
- when /(?i)QMRF/
- report = ReachReports::QmrfReport.get(id)
- when /(?i)QPRF/
- report = ReachReports::QprfReport.get(id)
+ report = nil
+ mysql_lite_retry(3) do
+ case type
+ when /(?i)QMRF/
+ report = ReachReports::QmrfReport.get(id)
+ when /(?i)QPRF/
+ report = ReachReports::QprfReport.get(id)
+ end
+ raise OpenTox::NotFoundError.new type+" report with id '#{id}' not found." unless report
end
- raise OpenTox::NotFoundError.new type+" report with id '#{id}' not found." unless report
return report
end
diff --git a/report/report_content.rb b/report/report_content.rb
index ca04f25..3e3c3d4 100755
--- a/report/report_content.rb
+++ b/report/report_content.rb
@@ -43,7 +43,8 @@ class Reports::ReportContent
section_test = @xml_report.add_section(@current_section, section_title)
@xml_report.add_paragraph(section_test, section_text) if section_text
- @xml_report.add_table(section_test, test_attribute.to_s+", significance-level: "+level.to_s, table, true, true)
+ @xml_report.add_table(section_test, test_attribute.to_s+", significance-level: "+level.to_s, table, true, true)
+ Reports::ReportStatisticalTest.quit_r
end
def add_predictions( validation_set,
diff --git a/report/statistical_test.rb b/report/statistical_test.rb
index c37827e..5e5ea3a 100644
--- a/report/statistical_test.rb
+++ b/report/statistical_test.rb
@@ -1,29 +1,35 @@
#require "rubygems"
#require "rinruby"
-#R.quit
module LIB
class StatisticalTest
- @@r = RinRuby.new(true,false)
-
# -1 -> array1 < array2
# 0 -> not difference
# 1 -> array2 > array1
#
def self.pairedTTest(array1, array2, significance_level=0.95)
+
+ @@r = RinRuby.new(true,false) unless defined?(@@r) and @@r
@@r.assign "v1",array1
@@r.assign "v2",array2
@@r.eval "ttest = t.test(v1,v2,paired=T)"
t = @@r.pull "ttest$statistic"
p = @@r.pull "ttest$p.value"
- #@@r.quit
if (1-significance_level > p)
t
else
0
end
end
+
+ def self.quit_r
+ begin
+ @@r.quit
+ @@r = nil
+ rescue
+ end
+ end
end
end
@@ -68,6 +74,11 @@ module Reports
LOGGER.debug "paired-t-testing "+attribute.to_s+" "+array1.inspect+" vs "+array2.inspect
LIB::StatisticalTest.pairedTTest(array1, array2, significance_level)
end
+
+ def self.quit_r
+ LIB::StatisticalTest.quit_r
+ end
+
end
end