diff options
author | Christoph Helma <helma@in-silico.ch> | 2016-10-14 09:55:51 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2016-10-14 09:55:51 +0200 |
commit | fbded88db8b51f41ffbd5a02f601e4538ec87258 (patch) | |
tree | 82ce46019ad490bef7547f7a67e40fc0b2bbd8e7 /lib/model.rb | |
parent | 09452bba5c407c27721223d126e3f45c12b20a0c (diff) |
git commit added to model metadata
Diffstat (limited to 'lib/model.rb')
-rw-r--r-- | lib/model.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/model.rb b/lib/model.rb index d7b072f..7503215 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -23,6 +23,7 @@ module OpenTox field :descriptor_means, type: Array, default:[] field :descriptor_sds, type: Array, default:[] field :scaled_variables, type: Array, default:[] + field :version, type: Hash, default:{} def self.create prediction_feature:nil, training_dataset:nil, algorithms:{} bad_request_error "Please provide a prediction_feature and/or a training_dataset." unless prediction_feature or training_dataset @@ -35,6 +36,16 @@ module OpenTox model.prediction_feature_id = prediction_feature.id model.training_dataset_id = training_dataset.id model.name = "#{prediction_feature.name} (#{training_dataset.name})" + # TODO: check if this works for gem version, add gem versioning? + dir = File.dirname(__FILE__) + commit = `cd #{dir}; git rev-parse HEAD`.chomp + branch = `cd #{dir}; git rev-parse --abbrev-ref HEAD`.chomp + url = `cd #{dir}; git config --get remote.origin.url`.chomp + if branch + model.version = {:url => url, :branch => branch, :commit => commit} + else + model.version = {:warning => "git is not installed"} + end # set defaults substance_classes = training_dataset.substances.collect{|s| s.class.to_s}.uniq |