summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@ot-dev.in-silico.ch>2011-02-25 17:53:25 +0000
committerroot <root@ot-dev.in-silico.ch>2011-02-25 17:53:25 +0000
commitc13727354eda6a71e0cb2b583b4e04efc1ee8a1e (patch)
tree062b38b0efa8a3f7eb5b89e24413884dd8af1fd0
parentb4513bfbf3a2d3e0c34de0765d4ea604e2f1500c (diff)
ohm/redis backend
-rw-r--r--application.rb20
-rw-r--r--lazar.rb2
2 files changed, 13 insertions, 9 deletions
diff --git a/application.rb b/application.rb
index eb6d53a..79063f5 100644
--- a/application.rb
+++ b/application.rb
@@ -24,16 +24,19 @@ class ModelStore
end
=end
-class PredictionCache
+class PredictionCache < Ohm::Model
# cache predictions
- include DataMapper::Resource
- property :id, Serial
- property :compound_uri, String, :length => 255
- property :model_uri, String, :length => 255
- property :dataset_uri, String, :length => 255
+ #include DataMapper::Resource
+ #attribute :id, Serial
+ attribute :compound_uri
+ attribute :model_uri
+ attribute :dataset_uri
+
+ index :compound_uri
+ index :model_uri
end
-DataMapper.auto_upgrade!
+#DataMapper.auto_upgrade!
before do
@accept = request.env['HTTP_ACCEPT']
@@ -139,7 +142,8 @@ end
delete '/?' do
# TODO delete datasets
FileUtils.rm Dir["public/*.yaml"]
- PredictionCache.auto_migrate!
+ PredictionCache.all.each {|cache| cache.delete }
+ #PredictionCache.auto_migrate!
response['Content-Type'] = 'text/plain'
"All models and cached predictions deleted."
end
diff --git a/lazar.rb b/lazar.rb
index 2f3b126..74680dd 100644
--- a/lazar.rb
+++ b/lazar.rb
@@ -85,7 +85,7 @@ post '/:id/?' do
response['Content-Type'] = 'text/uri-list'
if compound_uri
- cache = PredictionCache.first(:model_uri => @lazar.uri, :compound_uri => compound_uri)
+ cache = PredictionCache.find(:model_uri => @lazar.uri, :compound_uri => compound_uri).first
return cache.dataset_uri if cache and uri_available?(cache.dataset_uri)
begin
prediction_uri = @lazar.predict(compound_uri,true,@subjectid).uri