Skip to content

Commit 84baede

Browse files
authored
Merge pull request #13 from biosimulators/implement-set-get-reset
Tie into 'implement-set-get-reset' branch of biosimulators_utils
2 parents fa9f2b8 + 31fb8e7 commit 84baede

File tree

9 files changed

+290
-149
lines changed

9 files changed

+290
-149
lines changed

biosimulators_tellurium/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.1.33'
1+
__version__ = '0.1.34'

biosimulators_tellurium/core.py

Lines changed: 212 additions & 128 deletions
Large diffs are not rendered by default.

biosimulators_tellurium/data_model.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import collections
1111
import dataclasses
1212
import enum
13-
import roadrunner
14-
import typing
13+
# import roadrunner
14+
# import typing
1515

1616
__all__ = [
1717
'SedmlInterpreter',
@@ -280,16 +280,17 @@ class PreprocesssedTask(object):
280280
""" Processed information about a SED task
281281
282282
Attributes:
283-
road_runner (:obj:`roadrunner.RoadRunner`): Road Runner instance with model
284-
solver (:obj:`roadrunner.Integrator` or :obj:`roadrunner.SteadyStateSolver`): solver
285-
model_change_target_tellurium_id_map (:obj:`dict`): dictionary that maps the targets of
286-
changes to their corresponding tellurium identifiers (tuples of their type and index within their type)
287-
algorithm_kisao_id (:obj:`str`): KiSAO id of algorithm to execute
288-
variable_target_tellurium_observable_map (:obj:`dict`): dictionary that maps tuples of variable targets and
289-
symbols to their corresponding tellurium observable identifiers
283+
road_runners (:obj:`roadrunner.RoadRunner`): Road Runner instances with model, per task
284+
solver (:obj:`roadrunner.Integrator` or :obj:`roadrunner.SteadyStateSolver`): solver, per task
285+
model_change_target_tellurium_id_map (:obj:`dict`): dictionaries that map the targets of
286+
changes to their corresponding tellurium identifiers (tuples of their type and index within their type), per task
287+
algorithm_kisao_id (:obj:`str`): dictionaries of KiSAO id of algorithm to execute, per task
288+
variable_target_tellurium_observable_maps (:obj:`dict`): dictionary of dictionaries that map tuples of variable targets and
289+
symbols to their corresponding tellurium observable identifiers, per task
290290
"""
291-
road_runner: roadrunner.RoadRunner
292-
solver: typing.Union[roadrunner.Integrator, roadrunner.SteadyStateSolver]
293-
model_change_target_tellurium_id_map: dict
294-
algorithm_kisao_id: str
295-
variable_target_tellurium_observable_map: dict
291+
road_runners: dict
292+
# solvers is dict of this type: typing.Union[roadrunner.Integrator, roadrunner.SteadyStateSolver]
293+
solvers: dict
294+
model_change_target_tellurium_id_maps: dict
295+
algorithm_kisao_ids: dict
296+
variable_target_tellurium_observable_maps: dict

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
biosimulators_utils[logging] >= 0.1.180
1+
biosimulators_utils[logging] >= 0.1.183
22
kisao >= 2.33
33
libroadrunner >= 2.4.0
44
lxml
1.78 KB
Binary file not shown.

tests/fixtures/repeat_basic.omex

1.77 KB
Binary file not shown.
1.89 KB
Binary file not shown.

tests/fixtures/repeat_no_reset.omex

1.79 KB
Binary file not shown.

tests/test_core_main.py

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,9 @@ def test_exec_sed_task_error_handling_with_biosimulators(self):
445445
def test_exec_sed_task_with_preprocesssed_task(self):
446446
# configure simulation
447447
task = sedml_data_model.Task(
448+
id="task1",
448449
model=sedml_data_model.Model(
450+
id="model1",
449451
source=self.EXAMPLE_MODEL_FILENAME,
450452
language=sedml_data_model.ModelLanguage.SBML.value,
451453
changes=[
@@ -522,9 +524,9 @@ def test_exec_sed_task_with_preprocesssed_task(self):
522524
variable_results, log = core.exec_sed_task(task, variables, preprocessed_task=preprocessed_task)
523525
with self.assertRaises(AssertionError):
524526
numpy.testing.assert_allclose(variable_results['C'][-1], end_c)
525-
mid_c = preprocessed_task.road_runner['C']
526-
mid_m = preprocessed_task.road_runner['M']
527-
mid_x = preprocessed_task.road_runner['X']
527+
mid_c = preprocessed_task.road_runners[task.id]['C']
528+
mid_m = preprocessed_task.road_runners[task.id]['M']
529+
mid_x = preprocessed_task.road_runners[task.id]['X']
528530
self.assertIsInstance(mid_c, float)
529531

530532
variable_results, log = core.exec_sed_task(task, variables, preprocessed_task=preprocessed_task)
@@ -547,6 +549,8 @@ def test_exec_sed_task_with_preprocesssed_task(self):
547549
new_value=mid_x,
548550
),
549551
]
552+
for change in task.model.changes:
553+
change.model = task.model.id
550554
preprocessed_task = core.preprocess_sed_task(task, variables)
551555
variable_results, log = core.exec_sed_task(task, variables, preprocessed_task=preprocessed_task)
552556
numpy.testing.assert_allclose(variable_results['C'][-1], end_c)
@@ -581,6 +585,9 @@ def test_exec_sed_task_with_preprocesssed_task(self):
581585
new_value=str(mid_x),
582586
),
583587
]
588+
for change in task.model.changes:
589+
change.model = task.model.id
590+
preprocessed_task = core.preprocess_sed_task(task, variables)
584591
variable_results, log = core.exec_sed_task(task, variables, preprocessed_task=preprocessed_task)
585592
numpy.testing.assert_allclose(variable_results['C'][-1], end_c)
586593

@@ -751,8 +758,6 @@ def test_exec_sedml_docs_in_combine_archive(self):
751758
if log.exception:
752759
raise log.exception
753760

754-
self._assert_curated_combine_archive_outputs(dirname, reports=True, plots=True)
755-
756761
def test_exec_sedml_docs_in_combine_archive_with_all_algorithms(self):
757762
for sedml_interpreter in SedmlInterpreter.__members__.values():
758763
for alg in gen_algorithms_from_specs(self.SPECIFICATIONS_FILENAME).values():
@@ -824,6 +829,57 @@ def test_sim_with_docker_image(self):
824829

825830
self._assert_curated_combine_archive_outputs(self.dirname, reports=True, plots=True)
826831

832+
def test_repeated_task_with_change(self):
833+
for sedml_interpreter in SedmlInterpreter.__members__.values():
834+
simulator_config = SimulatorConfig()
835+
simulator_config.sedml_interpreter = sedml_interpreter
836+
837+
archive_filename = 'tests/fixtures/repeat_basic.omex'
838+
839+
dirname = os.path.join(self.dirname, sedml_interpreter.name, 'reports')
840+
_, log = core.exec_sedml_docs_in_combine_archive(archive_filename, dirname, simulator_config=simulator_config)
841+
if log.exception:
842+
raise log.exception
843+
844+
845+
def test_repeated_task_with_change_and_no_reset(self):
846+
for sedml_interpreter in SedmlInterpreter.__members__.values():
847+
simulator_config = SimulatorConfig()
848+
simulator_config.sedml_interpreter = sedml_interpreter
849+
850+
archive_filename = 'tests/fixtures/repeat_no_reset.omex'
851+
852+
dirname = os.path.join(self.dirname, sedml_interpreter.name, 'reports')
853+
_, log = core.exec_sedml_docs_in_combine_archive(archive_filename, dirname, simulator_config=simulator_config)
854+
if log.exception:
855+
raise log.exception
856+
857+
858+
def test_repeated_task_with_change_to_initial_assignment(self):
859+
for sedml_interpreter in SedmlInterpreter.__members__.values():
860+
simulator_config = SimulatorConfig()
861+
simulator_config.sedml_interpreter = sedml_interpreter
862+
863+
archive_filename = 'tests/fixtures/repeat_initial_assignment.omex'
864+
865+
dirname = os.path.join(self.dirname, sedml_interpreter.name, 'reports')
866+
_, log = core.exec_sedml_docs_in_combine_archive(archive_filename, dirname, simulator_config=simulator_config)
867+
if log.exception:
868+
raise log.exception
869+
870+
871+
def test_change_to_initial_assignment(self):
872+
for sedml_interpreter in SedmlInterpreter.__members__.values():
873+
simulator_config = SimulatorConfig()
874+
simulator_config.sedml_interpreter = sedml_interpreter
875+
876+
archive_filename = 'tests/fixtures/change_initial_assignment.omex'
877+
878+
dirname = os.path.join(self.dirname, sedml_interpreter.name, 'reports')
879+
_, log = core.exec_sedml_docs_in_combine_archive(archive_filename, dirname, simulator_config=simulator_config)
880+
if log.exception:
881+
raise log.exception
882+
827883
# helper methods
828884
def _get_combine_archive_exec_env(self):
829885
return {

0 commit comments

Comments
 (0)