From c358b2f83b6e3432f3d5486db0ae0037ebae8ef8 Mon Sep 17 00:00:00 2001 From: Robert Vickerstaff Date: Mon, 13 Nov 2023 15:50:59 +0000 Subject: [PATCH] added simple examples to test-ghactions.sh --- examples/test_data/valid_doc.sbml | 42 +++++++++++++++++++++++++++++++ pyneuroml/pynml.py | 2 +- pyneuroml/sbml/__init__.py | 3 ++- test-ghactions.sh | 7 ++++++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 examples/test_data/valid_doc.sbml diff --git a/examples/test_data/valid_doc.sbml b/examples/test_data/valid_doc.sbml new file mode 100644 index 000000000..578594a3b --- /dev/null +++ b/examples/test_data/valid_doc.sbml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + k + S1 + c1 + + + + + + + diff --git a/pyneuroml/pynml.py b/pyneuroml/pynml.py index edd98749b..2efc4f320 100644 --- a/pyneuroml/pynml.py +++ b/pyneuroml/pynml.py @@ -2143,7 +2143,7 @@ def evaluate_arguments(args): try: result = validate_sbml_files(args.input_files, strict_units) except Exception as e: - logger.critical(f"validate_sbml_files failed with {e.message}") + logger.critical(f"validate_sbml_files failed with {str(e)}") sys.exit(UNKNOWN_ERR) if result: diff --git a/pyneuroml/sbml/__init__.py b/pyneuroml/sbml/__init__.py index 6a4e2c5fe..c1ec3cf00 100644 --- a/pyneuroml/sbml/__init__.py +++ b/pyneuroml/sbml/__init__.py @@ -4,6 +4,7 @@ """ import os +import errno import libsbml from libsbml import SBMLReader from typing import List @@ -25,7 +26,7 @@ def validate_sbml_files(input_files: List[str], strict_units: bool = False) -> b # These checks are already implemented by SBMLReader # But could just be logged along with the other error types rather than causing exceptions if not os.path.isfile(file_name): - raise FileNotFoundError(f"Could not find SBML file {file_name}") + raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), file_name) if not os.access(file_name, os.R_OK): raise IOError(f"Could not read SBML file {file_name}") diff --git a/test-ghactions.sh b/test-ghactions.sh index aa261a1d3..4fd7c1e84 100755 --- a/test-ghactions.sh +++ b/test-ghactions.sh @@ -70,6 +70,13 @@ pynml LEMS_NML2_Ex9_FN.xml -spineml pynml LEMS_NML2_Ex9_FN.xml -sbml +echo +echo "################################################" +echo "## Simple SBML validation example" + +pynml -validate-sbml test_data/valid_doc.sbml +pynml -validate-sbml-units test_data/valid_doc.sbml + echo echo "################################################"