From ecdd0347a347bd2ac5fa9e6a41ec7475b007309d Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 10 Jan 2011 17:47:09 +0100 Subject: A&A extent --- lib/feature.rb | 4 ++-- lib/model.rb | 8 ++++---- lib/policy.rb | 9 +++++++++ lib/task.rb | 12 ++++++------ 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/feature.rb b/lib/feature.rb index 9e28077..349f8ae 100644 --- a/lib/feature.rb +++ b/lib/feature.rb @@ -2,10 +2,10 @@ module OpenTox class Feature include OpenTox - def self.find(uri) + def self.find(uri, subjectid=nil) feature = Feature.new uri if (CONFIG[:yaml_hosts].include?(URI.parse(uri).host)) - feature.add_metadata YAML.load(RestClientWrapper.get(uri,:accept => "application/x-yaml")) + feature.add_metadata YAML.load(RestClientWrapper.get(uri,{:accept => "application/x-yaml", :subjectid => subjectid})) else feature.add_metadata Parser::Owl::Dataset.new(uri).load_metadata end diff --git a/lib/model.rb b/lib/model.rb index 32f5604..7aa3f5c 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -60,8 +60,8 @@ module OpenTox # Get URIs of all lazar models # @return [Array] List of lazar model URIs - def self.all - RestClientWrapper.get(CONFIG[:services]["opentox-model"]).to_s.split("\n") + def self.all(subjectid=nil) + RestClientWrapper.get(CONFIG[:services]["opentox-model"], :subjectid => subjectid).to_s.split("\n") end # Find a lazar model @@ -77,7 +77,7 @@ module OpenTox def self.create(params) lazar_algorithm = OpenTox::Algorithm::Generic.new File.join( CONFIG[:services]["opentox-algorithm"],"lazar") model_uri = lazar_algorithm.run(params) - OpenTox::Model::Lazar.find(model_uri) + OpenTox::Model::Lazar.find(model_uri, params[:subjectid]) end # Get a parameter value @@ -98,7 +98,7 @@ module OpenTox DC.title => URI.decode(File.basename( @metadata[OT.dependentVariables] )), OT.parameters => [{DC.title => "dataset_uri", OT.paramValue => dataset_uri}] }) - d = Dataset.new(dataset_uri) + d = Dataset.new(dataset_uri,subjectid) d.load_compounds d.compounds.each do |compound_uri| predict(compound_uri,false,subjectid) diff --git a/lib/policy.rb b/lib/policy.rb index 0ef8298..9c81fbd 100644 --- a/lib/policy.rb +++ b/lib/policy.rb @@ -33,6 +33,15 @@ module OpenTox return true end + #drop all policies in a policies instance + def names + out = [] + @policies.each do |name, policy| + out << name + end + return out + end + #loads a default policy template in policies instance def load_default_policy(user, uri, group="member") template = case user diff --git a/lib/task.rb b/lib/task.rb index 18fba6e..9cf909f 100644 --- a/lib/task.rb +++ b/lib/task.rb @@ -50,12 +50,12 @@ module OpenTox cpu_load = `cat /proc/loadavg`.split(/\s+/)[0..2].collect{|c| c.to_f} nr_cpu_cores = `cat /proc/cpuinfo |grep "cpu cores"|cut -d ":" -f2|tr -d " "`.split("\n").collect{|c| c.to_i}.inject{|sum,n| sum+n} nr_cpu_cores = 1 if !nr_cpu_cores - if cpu_load[0] > nr_cpu_cores and cpu_load[0] > cpu_load[1] and cpu_load[1] > cpu_load[2] # average CPU load of the last minute is high and CPU load is increasing - LOGGER.warn "Cannot start task - CPU load too high (#{cpu_load.join(", ")})" - task.cancel - return task - #raise "Server too busy to start a new task" - end + #if cpu_load[0] > nr_cpu_cores and cpu_load[0] > cpu_load[1] and cpu_load[1] > cpu_load[2] # average CPU load of the last minute is high and CPU load is increasing + # LOGGER.warn "Cannot start task - CPU load too high (#{cpu_load.join(", ")})" + # task.cancel + # return task + # #raise "Server too busy to start a new task" + #end task_pid = Spork.spork(:logger => LOGGER) do -- cgit v1.2.3