diff --git a/biosimulators_utils/combine/exceptions.py b/biosimulators_utils/combine/exceptions.py index 29ff456f..30d127dd 100644 --- a/biosimulators_utils/combine/exceptions.py +++ b/biosimulators_utils/combine/exceptions.py @@ -10,9 +10,15 @@ __all__ = [ 'CombineArchiveExecutionError', + 'NoSedmlError', ] class CombineArchiveExecutionError(BioSimulatorsException): """ Error that a SED document could not be executed """ pass # pragma: no cover + + +class NoSedmlError(BioSimulatorsException): + """ Error that a COMBINE/OMEX archive does not contain any SED-ML files """ + pass # pragma: no cover diff --git a/biosimulators_utils/combine/exec.py b/biosimulators_utils/combine/exec.py index 349fc0bc..96de041c 100644 --- a/biosimulators_utils/combine/exec.py +++ b/biosimulators_utils/combine/exec.py @@ -16,11 +16,9 @@ from ..sedml.data_model import (SedDocument, Task, Output, Report, DataSet, Plot2D, Curve, # noqa: F401 Plot3D, Surface, Variable) from ..sedml.io import SedmlSimulationReader # noqa: F401 -from ..warnings import warn -from .exceptions import CombineArchiveExecutionError +from .exceptions import CombineArchiveExecutionError, NoSedmlError from .io import CombineArchiveReader from .utils import get_sedml_contents, get_summary_sedml_contents -from .warnings import NoSedmlWarning import datetime import glob import os @@ -116,7 +114,8 @@ def sed_doc_executer(doc, working_dir, base_out_path, rel_out_path=None, # determine files to execute sedml_contents = get_sedml_contents(archive) if not sedml_contents: - warn("COMBINE/OMEX archive '{}' does not contain any executing SED-ML files".format(archive_filename), NoSedmlWarning) + msg = "COMBINE/OMEX archive '{}' does not contain any executing SED-ML files".format(archive_filename) + raise NoSedmlError(msg) # print summary of SED documents print(get_summary_sedml_contents(archive, archive_tmp_dir)) diff --git a/biosimulators_utils/combine/warnings.py b/biosimulators_utils/combine/warnings.py index 19b83951..14fd8774 100644 --- a/biosimulators_utils/combine/warnings.py +++ b/biosimulators_utils/combine/warnings.py @@ -6,12 +6,4 @@ :License: MIT """ -from ..warnings import BioSimulatorsWarning - - -__all__ = ['NoSedmlWarning'] - - -class NoSedmlWarning(BioSimulatorsWarning): - """ Warning that a COMBINE/OMEX archive does not contain any SED-ML files """ - pass # pragma: no cover +__all__ = [] diff --git a/tests/combine/test_combine_exec.py b/tests/combine/test_combine_exec.py index d0fd75a4..e3e874ac 100644 --- a/tests/combine/test_combine_exec.py +++ b/tests/combine/test_combine_exec.py @@ -1,9 +1,8 @@ from biosimulators_utils.archive.io import ArchiveReader from biosimulators_utils.combine import exec from biosimulators_utils.combine.data_model import CombineArchive, CombineArchiveContent -from biosimulators_utils.combine.exceptions import CombineArchiveExecutionError +from biosimulators_utils.combine.exceptions import CombineArchiveExecutionError, NoSedmlError from biosimulators_utils.combine.io import CombineArchiveWriter -from biosimulators_utils.combine.warnings import NoSedmlWarning from biosimulators_utils.log import utils as log_utils from biosimulators_utils.log.warnings import StandardOutputNotLoggedWarning from biosimulators_utils.plot.data_model import PlotFormat @@ -87,7 +86,7 @@ def exec_sed_doc(task_executer, filename, working_dir, base_out_dir, archive.contents[0].format = 'unknown' CombineArchiveWriter().run(archive, in_dir, archive_filename) - with self.assertWarnsRegex(NoSedmlWarning, 'does not contain any executing SED-ML files'): + with self.assertRaisesRegex(NoSedmlError, 'does not contain any executing SED-ML files'): with mock.patch('biosimulators_utils.sedml.exec.exec_sed_doc', side_effect=exec_sed_doc): sed_doc_executer = functools.partial(exec_sed_doc, sed_task_executer) exec.exec_sedml_docs_in_archive(sed_doc_executer, archive_filename, out_dir,