Skip to content

Commit

Permalink
switching no SED-ML in COMBINE archive from warning to error; closes #26
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrkarr committed Mar 3, 2021
1 parent d1376cc commit b07d921
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
6 changes: 6 additions & 0 deletions biosimulators_utils/combine/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 3 additions & 4 deletions biosimulators_utils/combine/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
10 changes: 1 addition & 9 deletions biosimulators_utils/combine/warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = []
5 changes: 2 additions & 3 deletions tests/combine/test_combine_exec.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b07d921

Please sign in to comment.