Skip to content

Commit

Permalink
add graph count generation job to ncbo_cron
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jan 11, 2025
1 parent b7c6d34 commit 25e6c06
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
20 changes: 20 additions & 0 deletions bin/ncbo_cron
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,26 @@ runner.execute do |opts|
ontology_analytics_options[:scheduler_type] = :cron
ontology_analytics_options[:cron_schedule] = ontology_analytics_options[:cron_ontology_analytics]
logger.info "Setting up ontology analytics refresh job with #{ontology_analytics_options[:cron_ontology_analytics]}"; logger.flush
ontology_analytics_log_path = File.join(log_path, "#{log_filename_noExt}-graph-count.log")
ontology_analytics_logger = Logger.new(ontology_analytics_log_path)
NcboCron::Scheduler.scheduled_locking_job(ontology_analytics_options) do
logger.info "Starting graphs count refresh"; logger.flush
logger.info "Logging graphs count refresh details to #{ontology_analytics_log_path}"; logger.flush
t0 = Time.now
NcboCron::GraphsCounts.new.run(logger)
logger.info "Ontology graphs counts completed in #{Time.now - t0} sec."; logger.flush
logger.info "Finished graphs refresh"; logger.flush
end
end
end

if options[:enable_graph_counts]
analytics_thread = Thread.new do
ontology_analytics_options = options.dup
ontology_analytics_options[:job_name] = "ncbo_cron_graph_counts"
ontology_analytics_options[:scheduler_type] = :cron
ontology_analytics_options[:cron_schedule] = ontology_analytics_options[:cron_ontology_analytics]
logger.info "Setting up ontology analytics refresh job with #{ontology_analytics_options[:cron_ontology_analytics]}"; logger.flush
ontology_analytics_log_path = File.join(log_path, "#{log_filename_noExt}-ontology-analytics.log")
ontology_analytics_logger = Logger.new(ontology_analytics_log_path)
NcboCron::Scheduler.scheduled_locking_job(ontology_analytics_options) do
Expand Down
7 changes: 1 addition & 6 deletions bin/ncbo_generate_graph_count
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,5 @@ opt_parser.parse!

logger = Logger.new(options[:logfile])
puts "Processing details are logged to #{options[:logfile]}"
unless options[:savefile]
logger.error "Please provide a file to save the results as an argument to --store FILEPATH"
exit
end

NcboCron::GraphsCounts.run
NcboCron::GraphsCounts.run(logger, options[:savefile])
NcboCron::GraphsCounts.new.run(logger, options[:savefile])
2 changes: 2 additions & 0 deletions lib/ncbo_cron/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def config(&block)
@settings.enable_mapping_counts ||= true
# enable ontology analytics
@settings.enable_ontology_analytics ||= true
# enable graph count
@settings.enable_graphs_counts ||= true
# enable ontologies report
@settings.enable_ontologies_report ||= true
# enable index synchronization
Expand Down
4 changes: 2 additions & 2 deletions lib/ncbo_cron/graphs_counts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
module NcboCron
class GraphsCounts
SUBMISSION_DATA_GRAPH = 'http://data\.bioontology\.org/ontologies/[^/]+/submissions/\d+'
DATA_SAVE = 'reports/graph_counts.json'
DATA_SAVE = '../../reports/graph_counts.json'

def run(logger, file_path = nil)
file_path ||= "#{LinkedData.settings.repository_folder}/#{DATA_SAVE}"
file_path ||= DATA_SAVE
logger.info('Start generating graphs counts')
logger.info('Fetch ontologies data graphs')
@all_ontologies = LinkedData::Models::Ontology.all
Expand Down

0 comments on commit 25e6c06

Please sign in to comment.