From f79e24132c973409741e02a69d000b605fd4fe95 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 13 Aug 2026 17:23:09 -0700 Subject: [PATCH 1/2] feat: put bulk-load batch progress behind a debug flag append_triples_batch printed one line per batch unconditionally. A single unit test in a dependent gem (ontologies_linked_data) emits dozens of them, burying the test output that actually matters in progress lines that say nothing about the test. * new Goo.data_load_debug / Goo.data_load_debug? pair, mirroring the shape of queries_debug above it -- positional setter, not `=`, because it is called inside a Goo.configure block where `conf.x = v` would parse as a local assignment rather than a method call. * off by default in lib/goo.rb itself, so code paths that never reach Goo.config (unit tests in dependent gems, notably) get the quiet default without any change on their side. Opt back in with GOO_DATA_LOAD_DEBUG or a direct Goo.data_load_debug(true) when debugging a slow or failing load. * the env var is parsed for truthiness rather than taken raw, unlike the queries_debug line directly above it: GOO_DATA_LOAD_DEBUG=false is a non-empty String and would otherwise turn the output back ON. Same treatment as query_logging and use_cache. The error-path puts in the same method are deliberately left alone; whether those belong on stderr is a separate question. Co-Authored-By: Claude Opus 5 (1M context) --- lib/goo.rb | 12 ++++++++++++ lib/goo/config/config.rb | 5 +++++ lib/goo/sparql/client.rb | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/goo.rb b/lib/goo.rb index 3b2780e..0ae6bdc 100644 --- a/lib/goo.rb +++ b/lib/goo.rb @@ -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 @@ -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 diff --git a/lib/goo/config/config.rb b/lib/goo/config/config.rb index c4494e1..7fe4c1f 100644 --- a/lib/goo/config/config.rb +++ b/lib/goo/config/config.rb @@ -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) @@ -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}", diff --git a/lib/goo/sparql/client.rb b/lib/goo/sparql/client.rb index ef81669..7f6271e 100644 --- a/lib/goo/sparql/client.rb +++ b/lib/goo/sparql/client.rb @@ -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}" From af69fc9ce1501d295224618ad7ef52d1beaf35c4 Mon Sep 17 00:00:00 2001 From: Jennifer Vendetti Date: Thu, 13 Aug 2026 17:27:52 -0700 Subject: [PATCH 2/2] docs: document GOO_DATA_LOAD_DEBUG in config.rb.sample The sample documents every other knob (query logging depth/TTL, redis split, use_cache), so the new flag belongs there too. Left commented out, matching the other opt-in settings, so copying the sample keeps the quiet default. Co-Authored-By: Claude Opus 5 (1M context) --- config/config.rb.sample | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/config.rb.sample b/config/config.rb.sample index 53cf200..6a293e4 100644 --- a/config/config.rb.sample +++ b/config/config.rb.sample @@ -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'