Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenk committed Oct 28, 2015
2 parents 27e239d + 19d5840 commit c29a180
Show file tree
Hide file tree
Showing 16 changed files with 157 additions and 85 deletions.
52 changes: 52 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
APP_ROOT = Pathname.new(File.expand_path('..', __FILE__)).expand_path

class AppRootFilter < SimpleCov::Filter
def matches?(source_file)
source_file.filename.sub(/^#{excluded_path.to_s}.*/, '').empty?
end

def excluded_path
APP_ROOT.join(filter_argument).expand_path
end
end

def app_root
Pathname.new(File.expand_path('../../', __FILE__))
end

def gemset_definition_file
rbenv = app_root.join('.rbenv-gemsets')
rbenv if rbenv.exist?
end

def gemsets
file = gemset_definition_file
if File.exist? file.to_s
file.readlines.map(&:strip).select { |line| !line.empty? }
else
[]
end
end

if ENV['COVERAGE']
SimpleCov.start do
add_group "Controllers", "app/controllers"
add_group "FakeRecords", "app/fake_records"
add_group "Helpers", "app/helpers"
add_group "Models", "app/models"
add_group "Serializers", "app/serializers"
add_group "ViewHelpers", "app/viewhelpers"
add_group "Lib", "lib"

add_filter AppRootFilter.new('config/')
add_filter AppRootFilter.new('spec/')
add_filter AppRootFilter.new('test/')

gemsets.each do |gemset|
add_filter AppRootFilter.new("#{gemset}/")
end

# Set timeout for merging coverage results to 30 minutes
merge_timeout(30 * 60)
end
end
2 changes: 0 additions & 2 deletions app/helpers/navigation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ def ontology_nav_metadata
[
['Projects', locid_for(resource, :projects),
:projects],
['Categories', locid_for(resource, :categories),
:categories],
['Tasks', locid_for(resource, :tasks),
:tasks],
['License Models', locid_for(resource, :license_models),
Expand Down
9 changes: 7 additions & 2 deletions app/models/hets_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(msg = DEFAULT_MSG)

STATES = %w(free force-free busy)
MUTEX_KEY = :choose_hets_instance
FORCE_FREE_WAITING_PERIOD = 60.seconds
FORCE_FREE_WAITING_PERIOD = 1.days

attr_accessible :name, :uri, :state, :queue_size

Expand Down Expand Up @@ -50,7 +50,12 @@ def initialize(msg = DEFAULT_MSG)

def self.with_instance!
instance = choose!
result = yield(instance)
begin
result = yield(instance)
rescue StandardError
Semaphore.exclusively(MUTEX_KEY) { instance.finish_work! }
raise
end
Semaphore.exclusively(MUTEX_KEY) { instance.finish_work! }
result
end
Expand Down
1 change: 1 addition & 0 deletions app/models/proof_attempt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ProofAttempt < ActiveRecord::Base
belongs_to :proof_status
belongs_to :prover
belongs_to :proof_attempt_configuration
has_one :axiom_selection, through: :proof_attempt_configuration
has_one :prover_output
has_one :tactic_script
has_many :generated_axioms, dependent: :destroy
Expand Down
22 changes: 14 additions & 8 deletions app/models/sine_axiom_selection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def call
Semaphore.exclusively(lock_key) do
unless finished
cleanup
preprocess
preprocess unless other_finished_sine_axiom_selections.any?
select_axioms
mark_as_finished!
end
Expand Down Expand Up @@ -66,9 +66,8 @@ def calculate_commonness_table

# Number of axioms in which the symbol occurs
def calculate_commonness(symbol)
ssc = SineSymbolCommonness.
where(symbol_id: symbol.id,
axiom_selection_id: axiom_selection.id).first_or_initialize
ssc = sine_symbol_commonnesses.
where(symbol_id: symbol.id).first_or_initialize
unless ssc.commonness
ssc.commonness = query_commonness(symbol)
ssc.save!
Expand All @@ -88,10 +87,9 @@ def calculate_symbol_axiom_trigger_table
end

def calculate_symbol_axiom_trigger(symbol, axiom)
ssat = SineSymbolAxiomTrigger.
ssat = sine_symbol_axiom_triggers.
where(symbol_id: symbol.id,
axiom_id: axiom.id,
axiom_selection_id: axiom_selection.id).first_or_initialize
axiom_id: axiom.id).first_or_initialize
unless ssat.tolerance
ssat.tolerance = needed_tolerance(symbol, axiom)
ssat.save!
Expand All @@ -113,6 +111,14 @@ def commonness_of_least_common_symbol(axiom)
least_common_symbol(axiom).sine_symbol_commonness.commonness
end

def other_finished_sine_axiom_selections
goal.proof_attempts.includes(:axiom_selection).map(&:axiom_selection).
select do |as|
as.specific.class == self.class && as.finished &&
as.id != axiom_selection.id
end.map(&:specific)
end

def select_axioms
@selected_axioms = triggered_axioms_by_commonness_threshold.to_a
select_new_axioms(goal, 0)
Expand All @@ -123,7 +129,7 @@ def select_new_axioms(sentence, current_depth)
return if depth_limit_reached?(current_depth)
new_axioms = select_axioms_by_sentence(sentence) - @selected_axioms
@selected_axioms += new_axioms
new_axioms.each { |axiom| select_new_axioms(axiom, current_depth + 1) }
new_axioms.each { |axiom| select_new_axioms(axiom, current_depth + 2) }
end

def select_axioms_by_sentence(sentence)
Expand Down
5 changes: 5 additions & 0 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
.container
.row.flash-messages
= flash_messages
.row.flash-messages
.alert.alert-info
Do you want to support the development of Ontohub by testing? Visit
= link_to 'test.ontohub.org', 'http://test.ontohub.org'
for more information
.row
- if cover_visible?
= render partial: '/shared/cover'
Expand Down
3 changes: 0 additions & 3 deletions app/views/ontologies/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

= simple_form_for resource, url: resource_path(resource) do |f|
= f.input :name, as: :string
= f.label :categories
.col-lg-10.well
= render partial: 'categories', locals: {hide_well: true}
= f.input :ontology_type_id, collection: OntologyType.all
= f.association :formality_level, collection: FormalityLevel.all, as: :radio_buttons
= f.association :projects, collection: Project.all, as: :check_boxes
Expand Down
1 change: 0 additions & 1 deletion app/views/shared/_navbar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
/ For any visitor
= menu_entry 'Repositories', :repositories
= menu_entry Settings.OMS.pluralize.capitalize, :ontologies
= menu_entry 'Categories', :categories
= menu_entry 'Symbols', :symbols_search if !! Settings.display_symbols_tab
= menu_entry 'Logics', :logics
= menu_entry 'Mappings', :mappings
Expand Down
4 changes: 1 addition & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
# Subsites for ontologies
ontology_subsites = %i(
comments metadata graphs
projects categories tasks
projects tasks
)

ontology_api_subsites = %i(
Expand Down Expand Up @@ -536,7 +536,6 @@

resources :mappings, only: :index

resources :categories, :only => [:index, :show]
resources :projects
resources :tasks
resources :license_models
Expand Down Expand Up @@ -619,7 +618,6 @@
resources :ontology_versions, :only => [:index, :show, :new, :create], :path => 'versions' do
resource :oops_request, :only => [:show, :create]
end
resources :categories
resources :tasks
resources :license_models
resources :tools
Expand Down
10 changes: 10 additions & 0 deletions db/migrate/20151022144003_add_index_on_sine_commonness.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class AddIndexOnSineCommonness < ActiveRecord::Migration
def change
# We only want to send queries like
# SELECT "symbols".*, "sine_symbol_commonnesses".*
# FROM "symbols" LEFT OUTER JOIN "sine_symbol_commonnesses" ON "sine_symbol_commonnesses"."symbol_id" = "symbols"."id"
# ORDER BY sine_symbol_commonnesses.commonness ASC LIMIT 1
# Thus, we also add an index on the commonness.
add_index :sine_symbol_commonnesses, :commonness
end
end
20 changes: 15 additions & 5 deletions doc/productive_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,21 @@ Start the git daemon:

If there's a new version on http://www.elasticsearch.org/download/, just replace the version number.

sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.1.deb
sudo dpkg -i elasticsearch-1.4.1.deb
sudo service elasticsearch start
+ apt-get update
+ apt-get install openjdk-7-jre-headless -y
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.7.3.deb

Before you can start Elasticsearch you need to replace the `elasticsearch` user with the `esearch` user. Thats because there are only 8-character-accounts on our machines allowed. To do this you need to

+ dpkg --unpack elasticsearch-1.7.3.deb
+ sed -r -e '/^#?ES_(USER|GROUP)=/ { s,^#,, ; s,=.*,=esearch, }' -i /etc/default/elasticsearch.dpkg-new
+ sed -e '/rmdir/ s,$, || true,' -i /var/lib/dpkg/info/elasticsearch.postrm
+ dpkg --configure elasticsearch
+ update-rc.d elasticsearch defaults 95 10

Afterwards you can start it with

+ service elasticsearch start

If you want to test it, you can do

Expand Down
3 changes: 1 addition & 2 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
require File.expand_path("../../../spec/shared_helper", __FILE__)

require 'simplecov'
require 'sidekiq/testing'
require 'cucumber/rails'
require 'capybara/poltergeist'
Expand Down
22 changes: 22 additions & 0 deletions spec/models/hets_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@
headers: {}})
end

context 'error on execution' do
let!(:hets_instance) { create :hets_instance, state: 'free' }

it 're-raises the error' do
expect do
HetsInstance.with_instance! { raise 'my_error' }
end.to raise_error('my_error')
end

it 'frees the instance' do
chosen = nil
begin
HetsInstance.with_instance! do |instance|
chosen = instance
raise 'my_error'
end
rescue StandardError
expect(chosen.state).to eq('free')
end
end
end

context 'free, force-free and busy are available' do
let!(:free) { create :hets_instance, state: 'free' }
let!(:force_free) { create :hets_instance, state: 'force-free' }
Expand Down
29 changes: 28 additions & 1 deletion spec/models/sine_axiom_selection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
end
end

context 'parameter influence' do
context 'calling SInE' do
setup_hets
let(:repository) { create :repository }

Expand Down Expand Up @@ -130,6 +130,33 @@
pac
end

context 'not preprocessing if already preprocessed once' do
let(:proof_attempt_previous) { create :proof_attempt, theorem: theorem }
let(:sine_axiom_selection_previous) { create :sine_axiom_selection }
let!(:proof_attempt_configuration_previous) do
pac = proof_attempt.proof_attempt_configuration
pac.axiom_selection = subject.axiom_selection
sine_axiom_selection_previous.axiom_selection.
proof_attempt_configurations = [pac]
pac
end

before do
sine_axiom_selection_previous.call
allow(subject).to receive(:preprocess).and_call_original
end

it 'not calling preprocess' do
subject.call
expect(subject).not_to have_received(:preprocess)
end

it 'selecting axioms anyway' do
subject.call
expect(subject.axioms).not_to be_empty
end
end

context 'commonness threshold' do
context '0' do
before do
Expand Down
53 changes: 0 additions & 53 deletions spec/shared_helper.rb

This file was deleted.

6 changes: 1 addition & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'

require File.expand_path("../../spec/shared_helper", __FILE__)

include SharedHelper
use_simplecov if ENV['COVERAGE']

require 'simplecov'
require File.expand_path("../../config/environment", __FILE__)
require File.expand_path("../hets_helper", __FILE__)
require 'rspec/rails'
Expand Down

0 comments on commit c29a180

Please sign in to comment.