summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/algorithm.rb7
-rw-r--r--lib/config/config_ru.rb5
-rw-r--r--lib/environment.rb5
-rw-r--r--lib/validation.rb10
4 files changed, 22 insertions, 5 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb
index 7a25408..b573ea3 100644
--- a/lib/algorithm.rb
+++ b/lib/algorithm.rb
@@ -21,8 +21,11 @@ module OpenTox
def self.create_model(params)
LOGGER.debug params
LOGGER.debug File.basename(__FILE__) + ": creating model"
- resource = RestClient::Resource.new(File.join(@@config[:services]["opentox-algorithm"], "lazar"), :user => @@users[:users].keys[0], :password => @@users[:users].values[0], :content_type => "text/x-yaml")
- @uri = resource.post(:dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer")).chomp
+ LOGGER.debug File.join(@@config[:services]["opentox-algorithm"], "lazar")
+ #resource = RestClient::Resource.new(File.join(@@config[:services]["opentox-algorithm"], "lazar"), :user => @@users[:users].keys[0], :password => @@users[:users].values[0], :content_type => "text/x-yaml")
+ resource = RestClient::Resource.new(File.join(@@config[:services]["opentox-algorithm"], "lazar"), :user => @@users[:users].keys[0], :password => @@users[:users].values[0], :content_type => "application/x-yaml")
+ #@uri = resource.post(:dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer")).chomp
+ @uri = resource.post(:dataset_uri => params[:dataset_uri], :prediction_feature => params[:prediction_feature], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer")).body.chomp
end
def self.uri
diff --git a/lib/config/config_ru.rb b/lib/config/config_ru.rb
index 1d32c7e..8470f0e 100644
--- a/lib/config/config_ru.rb
+++ b/lib/config/config_ru.rb
@@ -18,3 +18,8 @@ set :raise_errors, true
end
use Rack::ShowExceptions
+#use Rack::MailExceptions do |mail|
+# mail.to '...@example.com'
+# mail.subject '[ERROR] %s'
+# mail.smtp MAIL
+#end
diff --git a/lib/environment.rb b/lib/environment.rb
index f89a758..44efd6e 100644
--- a/lib/environment.rb
+++ b/lib/environment.rb
@@ -40,13 +40,16 @@ if @@config[:database]
end
end
+# mail
+#load File.join config_dir,"mail.rb"
+
# hack: store sinatra in global var to make url_for and halt methods accessible
before {$sinatra = self unless $sinatra}
class Sinatra::Base
# overwriting halt to log halts (!= 202)
def halt(*response)
- LOGGER.error "halt "+response.first.to_s+" "+(response.size>1 ? response[1].to_s : "") if response.first >= 300
+ LOGGER.error "halt "+response.first.to_s+" "+(response.size>1 ? response[1].to_s : "") if response and response.first and response.first >= 300
# orig sinatra code:
response = response.first if response.length == 1
throw :halt, response
diff --git a/lib/validation.rb b/lib/validation.rb
index 6fd5704..97aafc4 100644
--- a/lib/validation.rb
+++ b/lib/validation.rb
@@ -4,8 +4,14 @@ module OpenTox
attr_accessor :uri
def initialize(params)
- resource = RestClient::Resource.new(params[:uri], :user => @@users[:users].keys[0], :password => @@users[:users].values[0])
- @uri = resource.post(params).to_s
+ #resource = RestClient::Resource.new(params[:uri], :user => @@users[:users].keys[0], :password => @@users[:users].values[0])
+ #@uri = resource.post(params).to_s
+ call = "curl -X POST "
+ params.each do |k,v|
+ call += " -d "+k.to_s+"=\""+v.to_s+"\"" unless k == :uri
+ end
+ call += " "+params[:uri]
+ LOGGER.debug call
end
def self.crossvalidation(params)