diff options
author | Martin Gütlein <martin.guetlein@gmail.com> | 2010-04-19 13:48:56 +0200 |
---|---|---|
committer | Martin Gütlein <martin.guetlein@gmail.com> | 2010-04-19 13:48:56 +0200 |
commit | 90110a7802aaae0652ad4a97a66b3360e559d9a2 (patch) | |
tree | 24475b05e1adc297e49ac2cb4b87510296d9d5c2 | |
parent | 6bed8b2a8feddf929d9ec0d08e590dfb41227e0e (diff) |
predict dataset is done with as_task for better error handling
-rw-r--r-- | lazar.rb | 20 |
1 files changed, 8 insertions, 12 deletions
@@ -3,7 +3,7 @@ class Lazar < Model attr_accessor :prediction_dataset def classify(compound_uri,prediction) - + prediction.title += " lazar classification" lazar = YAML.load self.yaml @@ -63,7 +63,10 @@ class Lazar < Model prediction.features << feature_uri prediction.data[compound_uri] = [] unless prediction.data[compound_uri] db_activities.each do |act| - prediction.data[compound_uri] << {feature_uri => act} + tuple = { + :classification => act, + :confidence => 1} + prediction.data[compound_uri] << {feature_uri => tuple} end true else @@ -174,22 +177,15 @@ post '/:id/?' do # create prediction halt 404, "Content type #{request.env['HTTP_ACCEPT']} not available." end - elsif dataset_uri - task = OpenTox::Task.create - pid = Spork.spork(:logger => LOGGER) do - task.started +elsif dataset_uri + response['Content-Type'] = 'text/uri-list' + OpenTox::Task.as_task do input_dataset = OpenTox::Dataset.find(dataset_uri) input_dataset.compounds.each do |compound_uri| lazar.classify(compound_uri,prediction) unless lazar.database_activity?(compound_uri,prediction) end uri = prediction.save.chomp - task.completed(uri) end - task.pid = pid - LOGGER.debug "Prediction task PID: " + pid.to_s - #status 303 - response['Content-Type'] = 'text/uri-list' - task.uri + "\n" end end |