diff options
Diffstat (limited to 'lib/model.rb')
-rw-r--r-- | lib/model.rb | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/model.rb b/lib/model.rb index 0073ea4..64d178f 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -17,25 +17,22 @@ module OpenTox end end LOGGER.info "running model "+@uri.to_s+", params: "+params.inspect+", accept: "+accept_header.to_s - RestClientWrapper.post(@uri,{:accept => accept_header},params,waiting_task).to_s + RestClientWrapper.post(@uri,params,{:accept => accept_header},waiting_task).to_s end # Generic OpenTox model class for all API compliant services class Generic include Model - # Find Generic Opentox Model via URI, and loads metadata + # Find Generic Opentox Model via URI, and loads metadata, could raise NotFound/NotAuthorized error # @param [String] uri Model URI - # @return [OpenTox::Model::Generic] Model instance, nil if model was not found + # @return [OpenTox::Model::Generic] Model instance def self.find(uri,subjectid=nil) return nil unless uri model = Generic.new(uri) model.load_metadata(subjectid) - if model.metadata==nil or model.metadata.size==0 - nil - else - model - end + raise "could not load model metadata '"+uri.to_s+"'" if model.metadata==nil or model.metadata.size==0 + model end # provides feature type, possible types are "regression" or "classification" @@ -46,7 +43,7 @@ module OpenTox @algorithm = OpenTox::Algorithm::Generic.find(@metadata[OT.algorithm], subjectid) unless @algorithm algorithm_title = @algorithm ? @algorithm.metadata[DC.title] : nil - @dependentVariable = OpenTox::Feature.find( @metadata[OT.dependentVariables], subjectid) unless @dependentVariable + @dependentVariable = OpenTox::Feature.find( @metadata[OT.dependentVariables],subjectid ) unless @dependentVariable [@dependentVariable.feature_type, @metadata[OT.isA], @metadata[DC.title], @uri, algorithm_title].each do |type| case type @@ -303,7 +300,7 @@ module OpenTox # Save model at model service def save(subjectid) - self.uri = RestClientWrapper.post(@uri,{:content_type => "application/x-yaml", :subjectid => subjectid},self.to_yaml) + self.uri = RestClientWrapper.post(@uri,self.to_yaml,{:content_type => "application/x-yaml", :subjectid => subjectid}) end # Delete model at model service |