summaryrefslogtreecommitdiff
path: root/lazar.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lazar.rb')
-rw-r--r--lazar.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lazar.rb b/lazar.rb
index e543802..13c3caa 100644
--- a/lazar.rb
+++ b/lazar.rb
@@ -45,6 +45,8 @@ end
post '/?' do # create model
halt 400, "MIME type \"#{request.content_type}\" not supported." unless request.content_type.match(/yaml/)
model = ModelStore.create
+ model.token_id = params[:token_id] if params[:token_id]
+ model.token_id = request.env["HTTP_TOKEN_ID"] if !model.token_id and request.env["HTTP_TOKEN_ID"]
model.uri = url_for("/#{model.id}", :full)
lazar = YAML.load request.env["rack.input"].read
lazar.uri = model.uri
@@ -66,6 +68,7 @@ post '/:id/?' do
halt 404, "No compound_uri or dataset_uri parameter." unless compound_uri = params[:compound_uri] or dataset_uri = params[:dataset_uri]
response['Content-Type'] = 'text/uri-list'
+
if compound_uri
cache = PredictionCache.first(:model_uri => @lazar.uri, :compound_uri => compound_uri)
return cache.dataset_uri if cache and uri_available?(cache.dataset_uri)
@@ -77,7 +80,6 @@ post '/:id/?' do
LOGGER.error "Lazar prediction failed for #{compound_uri} with #{$!} "
halt 500, "Prediction of #{compound_uri} with #{@lazar.uri} failed."
end
-
elsif dataset_uri
task = OpenTox::Task.create("Predict dataset",url_for("/#{@lazar.id}", :full)) do
@lazar.predict_dataset(dataset_uri).uri