From ba8c5664971e69ffc7b5d3f6dcfb123adf545ab9 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Thu, 27 Jul 2023 14:57:08 -0700 Subject: [PATCH 1/3] Allow getting values either from the get_value_executer or the XML. --- biosimulators_utils/sedml/exec.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/biosimulators_utils/sedml/exec.py b/biosimulators_utils/sedml/exec.py index f0209277..dfcc60f9 100644 --- a/biosimulators_utils/sedml/exec.py +++ b/biosimulators_utils/sedml/exec.py @@ -537,16 +537,23 @@ def exec_task(task, variables, preprocessed_task=None, log=None, config=None, ** variable_values = {} for variable in change.variables: if get_value_executer and preprocessed_task: - value = get_value_executer(change.model, variable, preprocessed_task) - variable_values[variable.id] = value - elif not apply_xml_model_changes: - raise NotImplementedError('Set value changes that involve variables of non-XML-encoded models are not supported.') - else: - variable_values[variable.id] = get_value_of_variable_model_xml_targets(variable, model_etrees) + try: + value = get_value_executer(change.model, variable, preprocessed_task) + variable_values[variable.id] = value + except: + # Even if the above fails, getting the value from the XML directly might be possible. + pass + if variable.id not in variable_values: + if not apply_xml_model_changes: + raise NotImplementedError('Set value changes that involve variables of non-XML-encoded models are not supported.') + else: + variable_values[variable.id] = get_value_of_variable_model_xml_targets(variable, model_etrees) new_value = calc_compute_model_change_new_value(change, variable_values=variable_values, range_values=current_range_values) if set_value_executer: + # Unlike above, we don't try to set values that the set_value_executer doesn't know about by editing the XML. + # This is because there's no good way to set some values this way and some with a model editor. set_value_executer(change.model, change.target, change.symbol, new_value, preprocessed_task) else: if new_value == int(new_value): From 8996035f7c9abe6a9caaeef828d7d64671845144 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Thu, 27 Jul 2023 14:58:06 -0700 Subject: [PATCH 2/3] Update version number. --- biosimulators_utils/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biosimulators_utils/_version.py b/biosimulators_utils/_version.py index 720a2bb1..b324b3e2 100644 --- a/biosimulators_utils/_version.py +++ b/biosimulators_utils/_version.py @@ -1 +1 @@ -__version__ = '0.1.185' +__version__ = '0.1.186' From c66519e40218595dc325a29b1bb8ad9d534dcd6a Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Thu, 27 Jul 2023 15:10:53 -0700 Subject: [PATCH 3/3] Lint fix. --- biosimulators_utils/sedml/exec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biosimulators_utils/sedml/exec.py b/biosimulators_utils/sedml/exec.py index dfcc60f9..97e86319 100644 --- a/biosimulators_utils/sedml/exec.py +++ b/biosimulators_utils/sedml/exec.py @@ -540,7 +540,7 @@ def exec_task(task, variables, preprocessed_task=None, log=None, config=None, ** try: value = get_value_executer(change.model, variable, preprocessed_task) variable_values[variable.id] = value - except: + except Exception: # Even if the above fails, getting the value from the XML directly might be possible. pass if variable.id not in variable_values: