Skip to content

Commit

Permalink
minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
robertvi committed Dec 11, 2023
1 parent b1854de commit 3e3bf95
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions test_suite/process_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
"""
produce a markdown table of the results of running various tests on the SBML Test Suite
get the version of the test suite that includes sedml versions
get this version of the test suite that includes sedml versions or the sedml validation will fail:
https://github.com/sbmlteam/sbml-test-suite/releases/download/3.4.0/semantic_tests_with_sedml_and_graphs.v3.4.0.zip
"""

import os
Expand Down Expand Up @@ -74,7 +72,7 @@ def add_case_url(case,fpath,url_base):
'''
insert URL link to original test case file online
effectively replaces args.suite_path with args.suite_url_base
this should produce a valid link for all the main intended use case
this should produce a valid link for all the main intended use cases
of testing the sbml test suite using the default args
but will not handle all possible variations of globs and base directories
in which case it should be disabled by setting --suite-url-base=''
Expand All @@ -85,26 +83,28 @@ def add_case_url(case,fpath,url_base):
return new_item

def process_cases(args):
"process the test cases and write results out as a markdown table"
"""
process the test cases and write results out as a markdown table
with links to the test case files online (as noted above the sedml files are actually in a zip file)
with a summary of how many cases were tested and how many tests failed
"""

header = "|case|valid-sbml|valid-sbml-units|valid-sedml|"
sep = "|---|---|---|---|"
row = "|{case}|{valid_sbml}|{valid_sbml_units}|{valid_sedml}|"
summary="|cases={n_cases}|fails={n_failing[valid_sbml]}|fails={n_failing[valid_sbml_units]}|fails={n_failing[valid_sedml]}|"
row = "|{case}|{valid_sbml}|{valid_sbml_units}|{valid_sedml}|"

with open(args.output_file, "w") as fout:
output = []
n_cases = 0
n_failing = {"valid_sbml":0, "valid_sbml_units":0, "valid_sedml":0 }

os.chdir(args.suite_path)

#accumulate output in memory so we can put the nifty summary at the top
#instead of at the end of 1800 lines
#instead of at the end of a very long table
output = []
output.append(header)
output.append(sep)
output.append("<results summary goes here>")
n_cases = 0
n_failing = {"valid_sbml":0, "valid_sbml_units":0, "valid_sedml":0 }

os.chdir(args.suite_path)
for fpath in sorted(glob.glob(args.suite_glob)):
sedml_path = fpath.replace(".xml", "-sedml.xml")
print(fpath)
Expand All @@ -117,14 +117,14 @@ def process_cases(args):
valid_sedml = pass_or_fail(validate_sedml_files([sedml_path]))
output.append(row.format(**locals()))

#tally results so we provide a summary
#tally results so we can provide a summary
global okay,fail
n_cases +=1
if valid_sbml != okay: n_failing["valid_sbml"] += 1
if valid_sbml_units != okay: n_failing["valid_sbml_units"] += 1
if valid_sedml != okay: n_failing["valid_sedml"] += 1
output[2] = summary.format(**locals())

output[2] = summary.format(**locals())
for line in output: fout.write(line+'\n')


Expand Down

0 comments on commit 3e3bf95

Please sign in to comment.