From 63d4ec2a99523c5b3a1ea8e2c72b8c0cfd4774ef Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Fri, 23 Jun 2023 14:19:41 -0700 Subject: [PATCH 01/12] Change base docker image. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e8cf636..4478f27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Base OS -FROM python:3.9-slim-buster +FROM python:3.11-slim-bookworm ARG VERSION="0.1.22" ARG SIMULATOR_VERSION="0.11.25" From 11c4d2eaf401c8b0850d2cb52fec3e9ef2d0b657 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Fri, 23 Jun 2023 14:23:49 -0700 Subject: [PATCH 02/12] Try Python 3.11 base, too. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e96266..786e4f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,7 +73,7 @@ jobs: - name: Install Python uses: actions/setup-python@v3 with: - python-version: '3.9' + python-version: '3.11' - name: Setup pip cache uses: actions/cache@v3 From becea9807f401e7005f9afbe2db88f18399419ac Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Fri, 23 Jun 2023 14:55:50 -0700 Subject: [PATCH 03/12] Install sympy by hand. It should be a requirement of amici, but perhaps it was missed? --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 4478f27..42a64a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,6 +45,7 @@ RUN apt-get update -y \ # Copy code for command-line interface into image and install it COPY . /root/Biosimulators_AMICI +RUN pip install sympy RUN pip install /root/Biosimulators_AMICI \ && rm -rf /root/Biosimulators_AMICI RUN pip install amici==${SIMULATOR_VERSION} From 3e7ce576915e322fcabf4ab54fd9bcf18511dbb5 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Fri, 23 Jun 2023 15:11:50 -0700 Subject: [PATCH 04/12] Try pinning pip to 23.0.1 As of 23.1, pip updated to no longer allow how all biosimulations projects are installed. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 42a64a0..b449ebb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,7 +45,7 @@ RUN apt-get update -y \ # Copy code for command-line interface into image and install it COPY . /root/Biosimulators_AMICI -RUN pip install sympy +RUN pip install pip==23.0.1 RUN pip install /root/Biosimulators_AMICI \ && rm -rf /root/Biosimulators_AMICI RUN pip install amici==${SIMULATOR_VERSION} From 3e0e2d950d1d31744463b1210edfdef262e62636 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Fri, 23 Jun 2023 15:23:00 -0700 Subject: [PATCH 05/12] Amici should have already been installed? Install it explicitly, but it shouldn't make a difference. --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b449ebb..1d4c079 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,9 +46,8 @@ RUN apt-get update -y \ # Copy code for command-line interface into image and install it COPY . /root/Biosimulators_AMICI RUN pip install pip==23.0.1 -RUN pip install /root/Biosimulators_AMICI \ +RUN pip install /root/Biosimulators_AMICI amici==${SIMULATOR_VERSION} \ && rm -rf /root/Biosimulators_AMICI -RUN pip install amici==${SIMULATOR_VERSION} ENV VERBOSE=0 \ MPLBACKEND=PDF From 55406a5258ed6d7a9d9c3e8708756d7f5b190ab9 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Fri, 23 Jun 2023 15:33:22 -0700 Subject: [PATCH 06/12] Explicitly install sympy. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1d4c079..8a197af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,7 @@ RUN apt-get update -y \ # Copy code for command-line interface into image and install it COPY . /root/Biosimulators_AMICI RUN pip install pip==23.0.1 -RUN pip install /root/Biosimulators_AMICI amici==${SIMULATOR_VERSION} \ +RUN pip install sympy /root/Biosimulators_AMICI amici==${SIMULATOR_VERSION} \ && rm -rf /root/Biosimulators_AMICI ENV VERBOSE=0 \ MPLBACKEND=PDF From 7d407fdc575aefdc15c3b3f015d132d4be3f6c6e Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Fri, 23 Jun 2023 15:45:20 -0700 Subject: [PATCH 07/12] Try not explicitly installing amici Explicitly installing it seems to have problems with sympy, even if sympy is clearly already installed. However, amici is a dependency of biosimulators_amici, so it should be installed already anyway? Let's see what happens. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8a197af..9c4b400 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,7 @@ RUN apt-get update -y \ # Copy code for command-line interface into image and install it COPY . /root/Biosimulators_AMICI RUN pip install pip==23.0.1 -RUN pip install sympy /root/Biosimulators_AMICI amici==${SIMULATOR_VERSION} \ +RUN pip install sympy /root/Biosimulators_AMICI \ # amici==${SIMULATOR_VERSION} \ && rm -rf /root/Biosimulators_AMICI ENV VERBOSE=0 \ MPLBACKEND=PDF From 2c09e28f9631df34dbbc6e2f5c6abbef98cd2c20 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Fri, 23 Jun 2023 15:50:41 -0700 Subject: [PATCH 08/12] Fix comment. --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9c4b400..ef67fea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,8 +46,10 @@ RUN apt-get update -y \ # Copy code for command-line interface into image and install it COPY . /root/Biosimulators_AMICI RUN pip install pip==23.0.1 -RUN pip install sympy /root/Biosimulators_AMICI \ # amici==${SIMULATOR_VERSION} \ +RUN pip install sympy /root/Biosimulators_AMICI \ && rm -rf /root/Biosimulators_AMICI +#RUN pip install sympy /root/Biosimulators_AMICI amici==${SIMULATOR_VERSION} \ +# && rm -rf /root/Biosimulators_AMICI ENV VERBOSE=0 \ MPLBACKEND=PDF From d241e34d803b239a613f156db389c3ab84e29a2c Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Sat, 24 Jun 2023 08:51:28 +0200 Subject: [PATCH 09/12] Fix observable IDs IDs in AMICI models have to be globally unique. Fixes errors of type `E amici.import_utils.SBMLException: AMICI tried to add a local symbol AL with value AL, but AL was already instantiated with AL. This means that there are multiple SBML elements with SId AL, which is invalid SBML. This can be fixed by renaming the elements with SId AL.` --- biosimulators_amici/core.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/biosimulators_amici/core.py b/biosimulators_amici/core.py index 5689298..bcc17cb 100644 --- a/biosimulators_amici/core.py +++ b/biosimulators_amici/core.py @@ -280,7 +280,7 @@ def import_model_from_sbml(filename, variables): model_dir = tempfile.mkdtemp() model_name = 'biosimulators_amici_model_' + os.path.basename(model_dir) constant_parameters = [param.getId() for param in sbml_model.parameters if param.constant] - observables = {var: {'name': var, 'formula': var} for var in variables} + observables = {variable_id_to_observable_id(var): {'name': var, 'formula': var} for var in variables} sbml_importer.sbml2amici(model_name, model_dir, observables=observables, @@ -456,7 +456,7 @@ def validate_variables(model, variables, variable_target_sbml_id_map): unpredicted_symbols = [] unpredicted_targets = [] - sbml_id_to_obs_index = {id: index for index, id in enumerate(model.getObservableIds())} + obs_id_to_obs_index = {id: index for index, id in enumerate(model.getObservableIds())} for variable in variables: if variable.symbol: @@ -467,7 +467,7 @@ def validate_variables(model, variables, variable_target_sbml_id_map): else: sbml_id = variable_target_sbml_id_map.get(variable.target, None) - i_obs = sbml_id_to_obs_index.get(sbml_id, None) + i_obs = obs_id_to_obs_index.get(variable_id_to_observable_id(sbml_id), None) if i_obs is None: unpredicted_targets.append(variable.target) else: @@ -566,3 +566,12 @@ def preprocess_sed_task(task, variables, config=None): } }, } + + +def variable_id_to_observable_id(variable_id: str) -> str: + """Convert a variable ID to an observable ID. + + In AMICI, identifiers need to be globally unique. Therefore, we cannot use a species ID as an observable ID. + Let's hope that this alias does not already exist in the model... + """ + return f"___{variable_id}" From ed7644f7e6eb82dd4dc6617ca1b4e92418041dc1 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Sat, 24 Jun 2023 12:54:38 -0700 Subject: [PATCH 10/12] Set actual value, not 'none'. --- tests/test_core_main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_core_main.py b/tests/test_core_main.py index f0d75ce..70cd2c8 100644 --- a/tests/test_core_main.py +++ b/tests/test_core_main.py @@ -251,7 +251,7 @@ def test_exec_sed_task_with_changes(self): model.changes.append(sedml_data_model.ModelAttributeChange( target="/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id='{}']".format(variable_id), target_namespaces=self.NAMESPACES, - new_value=None)) + new_value=1.3)) variables.append(sedml_data_model.Variable( id=variable_id, target="/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id='{}']".format(variable_id), @@ -673,3 +673,6 @@ def test_exec_sedml_docs_in_combine_archive_with_docker_image(self): archive_filename, out_dir, docker_image, environment=env, pull_docker_image=False) self._assert_combine_archive_outputs(doc, out_dir) + +if __name__ == "__main__": + unittest.main() From d761f42b3b40388249e1f3fe1fbf984ece673ff6 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Sat, 24 Jun 2023 13:35:44 -0700 Subject: [PATCH 11/12] Relax tolerance (Might have the argument names wrong) --- tests/test_core_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_core_main.py b/tests/test_core_main.py index 70cd2c8..0c1862a 100644 --- a/tests/test_core_main.py +++ b/tests/test_core_main.py @@ -287,7 +287,7 @@ def test_exec_sed_task_with_changes(self): for variable_id in variable_ids: numpy.testing.assert_allclose( results3[variable_id], - results[variable_id][-int(sim.number_of_points + 1):], + results[variable_id][-int(sim.number_of_points + 1):], rtol=1e-5, atol=1e-4 ) task.model.changes = [ From aff6b4b8cf6b561594260602b8621d9681f467e0 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Sat, 24 Jun 2023 16:00:08 -0700 Subject: [PATCH 12/12] Remove sphinxprettysearchresults It broke, and isn't being updated. --- docs-src/conf.py | 1 - docs-src/requirements.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/docs-src/conf.py b/docs-src/conf.py index 23eca24..24dceeb 100644 --- a/docs-src/conf.py +++ b/docs-src/conf.py @@ -42,7 +42,6 @@ 'sphinx.ext.autodoc', 'sphinx.ext.linkcode', 'sphinx.ext.napoleon', - 'sphinxprettysearchresults', ] # Add any paths that contain templates here, relative to this directory. diff --git a/docs-src/requirements.txt b/docs-src/requirements.txt index 41c3485..05a0f7f 100644 --- a/docs-src/requirements.txt +++ b/docs-src/requirements.txt @@ -1,3 +1,2 @@ pydata-sphinx-theme sphinx >= 1.8 -sphinxprettysearchresults