From c1dbd8bcc5ec8a299461b47ddfb6a835a984a8ca Mon Sep 17 00:00:00 2001 From: Alex Skrenchuk Date: Fri, 2 Feb 2024 12:54:01 -0800 Subject: [PATCH] re-implement PR#55, fix for remote ontology pull with gzipped submissions NCBO code was refactored after PR#55 was made which made merging original pr a bit tricky. This change incorporates changes introduced in PR#55 --- lib/ncbo_cron/ontology_helper.rb | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/lib/ncbo_cron/ontology_helper.rb b/lib/ncbo_cron/ontology_helper.rb index 42534768..8840f4fd 100644 --- a/lib/ncbo_cron/ontology_helper.rb +++ b/lib/ncbo_cron/ontology_helper.rb @@ -101,32 +101,17 @@ def self.create_submission(ont, sub, file, filename, logger = nil, add_to_queue new_sub.submissionStatus = nil new_sub.creationDate = nil new_sub.missingImports = nil + new_sub.masterFileName = nil new_sub.metrics = nil full_file_path = File.expand_path(file_location) # check if OWLAPI is able to parse the file before creating a new submission - owlapi = LinkedData::Parser::OWLAPICommand.new( - full_file_path, - File.expand_path(new_sub.data_folder.to_s), - logger: logger) - owlapi.disable_reasoner - parsable = true - - begin - owlapi.parse - rescue Exception => e - logger.error("The new file for ontology #{ont.acronym}, submission id: #{submission_id} did not clear OWLAPI: #{e.class}: #{e.message}\n#{e.backtrace.join("\n\t")}") - logger.error("A new submission has NOT been created.") - logger.flush - parsable = false - end - - if parsable + if new_sub.parsable?(logger: logger) if new_sub.valid? - new_sub.save() + new_sub.save if add_to_queue - self.queue_submission(new_sub, { all: true }) + queue_submission(new_sub, { all: true }) logger.info("OntologyPull created a new submission (#{submission_id}) for ontology #{ont.acronym}") end else @@ -134,6 +119,9 @@ def self.create_submission(ont, sub, file, filename, logger = nil, add_to_queue logger.flush end else + logger.error("The new file for ontology #{ont.acronym}, submission id: #{submission_id} did not clear OWLAPI: #{e.class}: #{e.message}\n#{e.backtrace.join("\n\t")}") + logger.error("A new submission has NOT been created.") + logger.flush # delete the bad file File.delete full_file_path if File.exist? full_file_path end @@ -182,4 +170,4 @@ def self.new_file_exists?(file, last) end end -end \ No newline at end of file +end