Skip to content

Commit 8319482

Browse files
authored
Merge pull request #183 from ncbo/develop
Merge branch 'develop'
2 parents ee0013f + 13f2d6e commit 8319482

6 files changed

Lines changed: 37 additions & 33 deletions

File tree

.github/workflows/ruby-unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
backend: ['ruby', 'ruby-agraph'] # ruby runs tests with 4store backend and ruby-agraph runs with AllegroGraph backend
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- name: Set up solr configsets
1717
run: ./test/solr/generate_ncbo_configsets.sh
1818
- name: create config.rb file

docker-compose.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ services:
5959
GOO_BACKEND_NAME: ag
6060
GOO_PORT: 10035
6161
GOO_HOST: agraph-ut
62-
GOO_PATH_QUERY: /repositories/bioportal_test
63-
GOO_PATH_DATA: /repositories/bioportal_test/statements
64-
GOO_PATH_UPDATE: /repositories/bioportal_test/statements
62+
GOO_PATH_QUERY: /repositories/ontoportal_test
63+
GOO_PATH_DATA: /repositories/ontoportal_test/statements
64+
GOO_PATH_UPDATE: /repositories/ontoportal_test/statements
6565
profiles:
6666
- agraph
6767
depends_on:
@@ -92,7 +92,7 @@ services:
9292
image: solr:8
9393
volumes:
9494
- ./test/solr/configsets:/configsets:ro
95-
#ports:
95+
# ports:
9696
# - "8983:8983"
9797
command: ["solr-precreate", "term_search_core1", "/configsets/term_search"]
9898
healthcheck:
@@ -106,7 +106,7 @@ services:
106106
image: solr:8
107107
volumes:
108108
- ./test/solr/configsets:/configsets:ro
109-
#ports:
109+
# ports:
110110
# - "8984:8983"
111111
command: ["solr-precreate", "prop_search_core1", "/configsets/property_search"]
112112
healthcheck:
@@ -117,26 +117,26 @@ services:
117117
retries: 5
118118

119119
agraph-ut:
120-
image: franzinc/agraph:v8.0.0
120+
image: franzinc/agraph:v8.0.1
121121
platform: linux/amd64
122122
environment:
123123
- AGRAPH_SUPER_USER=test
124124
- AGRAPH_SUPER_PASSWORD=xyzzy
125125
shm_size: 1g
126-
# ports:
127-
# - 10035:10035
126+
# ports:
127+
# - 10035:10035
128128
command: >
129129
bash -c "/agraph/bin/agraph-control --config /agraph/etc/agraph.cfg start
130-
; agtool repos create bioportal_test
130+
; agtool repos create --supersede ontoportal_test
131131
; agtool users add anonymous
132-
; agtool users grant anonymous root:bioportal_test:rw
132+
; agtool users grant anonymous root:ontoportal_test:rw
133133
; tail -f /agraph/data/agraph.log"
134134
healthcheck:
135-
test: ["CMD-SHELL", "agtool storage-report bioportal_test || exit 1"]
136-
start_period: 10s
137-
interval: 60s
138-
timeout: 5s
139-
retries: 3
135+
test: ["CMD-SHELL", "agtool storage-report ontoportal_test || exit 1"]
136+
start_period: 30s #AllegroGraph can take a loooooong time to start
137+
interval: 20s
138+
timeout: 10s
139+
retries: 20
140140
profiles:
141141
- agraph
142142

lib/ontologies_linked_data/metrics/metrics.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def self.metrics_for_submission(submission, logger)
3535
logger.flush
3636

3737
# re-generate metrics file
38-
submission.generate_metrics_file2(cls_metrics[:classes], indiv_count, prop_count, cls_metrics[:maxDepth])
38+
submission.generate_metrics_file(cls_metrics[:classes], indiv_count, prop_count, cls_metrics[:maxDepth])
3939
logger.info("generation of metrics file finished")
4040
logger.flush
4141

@@ -54,10 +54,11 @@ def self.max_depth_fn(submission, logger, is_flat, rdfsSC)
5454
if (mx_from_file && mx_from_file.length == 2 && mx_from_file[0].length >= 4)
5555
then
5656
max_depth = mx_from_file[1][3].to_i
57+
logger.info("Metrics max_depth retrieved #{max_depth} from the metrics csv file.")
5758
else
5859
logger.info("Unable to find metrics providing max_depth in file for submission #{submission.id.to_s}. Using ruby calculation of max_depth.")
5960
roots = submission.roots
60-
61+
6162
unless is_flat
6263
depths = []
6364
roots.each do |root|

lib/ontologies_linked_data/models/ontology_submission.rb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -418,41 +418,43 @@ def metrics_from_file(logger=nil)
418418
metrics
419419
end
420420

421-
def generate_metrics_file(class_count, indiv_count, prop_count)
422-
CSV.open(self.metrics_path, "wb") do |csv|
423-
csv << ["Class Count", "Individual Count", "Property Count"]
424-
csv << [class_count, indiv_count, prop_count]
425-
end
426-
end
427-
428-
def generate_metrics_file2(class_count, indiv_count, prop_count, max_depth)
421+
def generate_metrics_file(class_count, indiv_count, prop_count, max_depth)
429422
CSV.open(self.metrics_path, "wb") do |csv|
430423
csv << ["Class Count", "Individual Count", "Property Count", "Max Depth"]
431424
csv << [class_count, indiv_count, prop_count, max_depth]
432425
end
433426
end
434427

435428
def generate_umls_metrics_file(tr_file_path=nil)
436-
tr_file_path ||= self.triples_file_path
429+
tr_file_path ||= triples_file_path
437430
class_count = 0
438431
indiv_count = 0
439432
prop_count = 0
433+
max_depth = 0
440434

441435
File.foreach(tr_file_path) do |line|
442436
class_count += 1 if line =~ /owl:Class/
443437
indiv_count += 1 if line =~ /owl:NamedIndividual/
444438
prop_count += 1 if line =~ /owl:ObjectProperty/
445439
prop_count += 1 if line =~ /owl:DatatypeProperty/
446440
end
447-
self.generate_metrics_file(class_count, indiv_count, prop_count)
441+
442+
# Get max depth from the metrics.csv file which is already generated
443+
# by owlapi_wrapper when new submission of UMLS ontology is created.
444+
# Ruby code/sparql for calculating max_depth fails for large UMLS
445+
# ontologie with AllegroGraph backend
446+
metrics_from_owlapi = metrics_from_file
447+
max_depth = metrics_from_owlapi[1][3] unless metrics_from_owlapi.empty?
448+
449+
generate_metrics_file(class_count, indiv_count, prop_count, max_depth)
448450
end
449451

450452
def generate_rdf(logger, reasoning: true)
451453
mime_type = nil
452454

453455
if self.hasOntologyLanguage.umls?
454456
triples_file_path = self.triples_file_path
455-
logger.info("Using UMLS turtle file found, skipping OWLAPI parse")
457+
logger.info("UMLS turtle file found; doing OWLAPI parse to extract metrics")
456458
logger.flush
457459
mime_type = LinkedData::MediaTypes.media_type_from_base(LinkedData::MediaTypes::TURTLE)
458460
generate_umls_metrics_file(triples_file_path)

run-unit-tests.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ DC='docker compose'
1111
test/solr/generate_ncbo_configsets.sh
1212

1313
# build docker containers
14-
$DC run --rm ruby bundle exec rake test TESTOPTS='-v'
14+
#$DC run --rm ruby bundle exec rake test TESTOPTS='-v'
1515
# run unit test with AG backend
16-
#$DC run --rm ruby-agraph bundle exec rake test TESTOPTS='-v'
17-
$DC stop
16+
$DC run --rm ruby-agraph bundle exec rake test TESTOPTS='-v'
17+
18+
$DC --profile agraph --profile 4store stop

test/models/test_ontology_submission.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ def test_umls_metrics_file
603603
metrics = sub.metrics_from_file(Logger.new(sub.parsing_log_path))
604604
assert !metrics.nil?, "Metrics is nil: #{metrics}"
605605
assert !metrics.empty?, "Metrics is empty: #{metrics}"
606-
metrics.each { |m| assert_equal 3, m.length }
606+
metrics.each { |m| assert_equal 4, m.length }
607607
assert_equal "Individual Count", metrics[0][1]
608608
assert_equal 133, metrics[1][0].to_i
609609
end

0 commit comments

Comments
 (0)