Skip to content

Commit

Permalink
re-implement PR#55, fix for remote ontology pull with gzipped submiss…
Browse files Browse the repository at this point in the history
…ions

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
  • Loading branch information
alexskr committed Feb 2, 2024
1 parent 8e3d46f commit c1dbd8b
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions lib/ncbo_cron/ontology_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,39 +101,27 @@ 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
logger.error("Unable to create a new submission for ontology #{ont.acronym} with id #{submission_id}: #{new_sub.errors}")
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
Expand Down Expand Up @@ -182,4 +170,4 @@ def self.new_file_exists?(file, last)

end
end
end
end

0 comments on commit c1dbd8b

Please sign in to comment.