Skip to content

Commit

Permalink
Two fixes:
Browse files Browse the repository at this point in the history
* Better error message for trying to change local parameter in a task
* Correctly store task change targets in nested repeated tasks.
  • Loading branch information
luciansmith committed Aug 16, 2023
1 parent eed7e34 commit 1bf666c
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions biosimulators_tellurium/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,22 @@ def get_all_tasks_from_task(task):
return ret
elif isinstance(task, RepeatedTask):
for sub_task in task.sub_tasks:
submodels = get_all_tasks_from_task(sub_task.task)
ret.update(submodels)
subtasks = get_all_tasks_from_task(sub_task.task)
ret.update(subtasks)
return ret
else:
raise NotImplementedError("Tasks other than 'Task' or 'RepeatedTask' are not supported.")


def get_all_task_changes_from_task(task):
ret = set()
if isinstance(task, Task):
return ret
elif isinstance(task, RepeatedTask):
ret.update(task.changes)
for sub_task in task.sub_tasks:
subtask_changes = get_all_task_changes_from_task(sub_task.task)
ret.update(subtask_changes)
return ret
else:
raise NotImplementedError("Tasks other than 'Task' or 'RepeatedTask' are not supported.")
Expand Down Expand Up @@ -352,6 +366,7 @@ def preprocess_sed_task(task, variables, config=None, simulator_config=None):
config = get_config()

alltasks = get_all_tasks_from_task(task)
alltaskchanges = get_all_task_changes_from_task(task)

if config.VALIDATE_SEDML:
for subtask in alltasks:
Expand All @@ -377,9 +392,7 @@ def preprocess_sed_task(task, variables, config=None, simulator_config=None):
solvers = {}
for subtasks in alltasks:
model = subtask.model
allchanges = model.changes
if isinstance(task, RepeatedTask):
allchanges = allchanges + task.changes
allchanges = model.changes + list(alltaskchanges)
sim = subtask.simulation
model_etree = lxml.etree.parse(model.source)

Expand Down Expand Up @@ -554,6 +567,9 @@ def get_model_change_target_tellurium_change_map(model_etree, changes, alg_kisao
else:
change.symbol = None
__, sep, __ = change.target.rpartition('/@')

if "reaction[" in change.target and "kineticLaw/" in change.target:
raise NotImplementedError("Unable to process a change to model " + model_id + " with the target " + change.target + " because changing local parameters is not yet implemented.")

sbml_id = change_targets_to_sbml_ids[change.target]

Expand Down

0 comments on commit 1bf666c

Please sign in to comment.