Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/config.rb.sample
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ Goo.config do |config|
# whether it is published to API callers.
config.queries_debug = false

# Per-batch progress lines while bulk-loading triples (env: GOO_DATA_LOAD_DEBUG). Off by
# default: append_triples_batch emits one line per batch, and a single unit test in a
# dependent gem produces dozens of them. Turn on when debugging a slow or failing load.
# config.data_load_debug = true

# SPARQL query logging (off by default; env equivalent OP_QUERIES_LOGGING).
# config.query_logging = true
# config.query_logging_file = '/var/log/goo/sparql.log'
Expand Down
12 changes: 12 additions & 0 deletions lib/goo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ module Goo
@@pluralize_models = false
@@uuid = UUID.new
@@debug_enabled = false
@@data_load_debug = false
@@use_cache = false
@@query_logging = false
@@query_logging_file = nil
Expand Down Expand Up @@ -214,6 +215,17 @@ def self.queries_debug?
return @@debug_enabled
end

# Per-batch progress lines during bulk triple loading. Off by default: append_triples_batch
# emits one line per chunk, which drowns the unit-test output of dependent gems
# (ontologies_linked_data) in thousands of lines that say nothing about the test.
def self.data_load_debug(flag)
@@data_load_debug = flag
end

def self.data_load_debug?
return @@data_load_debug
end

def self.add_search_backend(name, *opts)
opts = opts[0]
unless opts.include? :service
Expand Down
5 changes: 5 additions & 0 deletions lib/goo/config/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def config(&block)
@settings.query_logging_max_logs ||= (ENV['OP_QUERIES_LOGGING_MAX_LOGS'] || 10_000).to_i
@settings.query_logging_ttl ||= (ENV['OP_QUERIES_LOGGING_TTL'] || 86_400).to_i
@settings.queries_debug ||= ENV['QUERIES_DEBUG'] || false
# Bulk-load progress lines (one per triple batch). Parse truthiness rather than taking the
# raw string -- GOO_DATA_LOAD_DEBUG=false is a non-empty String and would otherwise turn the
# output ON (same treatment as query_logging above).
@settings.data_load_debug ||= %w[1 true yes on].include?(ENV['GOO_DATA_LOAD_DEBUG'].to_s.strip.downcase)
# SPARQL query caching: goo default OFF; env-driven opt-in so production can flip caching
# without a code change (de-fork review D5).
@settings.use_cache ||= %w[1 true yes on].include?(ENV['OP_USE_CACHE'].to_s.strip.downcase)
Expand All @@ -65,6 +69,7 @@ def connect_goo
begin
Goo.configure do |conf|
conf.queries_debug(@settings.queries_debug)
conf.data_load_debug(@settings.data_load_debug)
conf.add_sparql_backend(:main,
backend_name: @settings.goo_backend_name,
query: "http://#{@settings.goo_host}:#{@settings.goo_port}#{@settings.goo_path_query}",
Expand Down
2 changes: 1 addition & 1 deletion lib/goo/sparql/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def delete_data_graph(graph)

def append_triples_batch(graph, triples, mime_type_in, current_line = 0)
begin
puts "Appending triples in batch of #{triples.size} triples from line #{current_line}"
puts "Appending triples in batch of #{triples.size} triples from line #{current_line}" if Goo.data_load_debug?
execute_append_request graph, triples.join, mime_type_in
rescue RestClient::Exception => e
puts "Error in appending triples request: #{e.response}"
Expand Down
Loading