Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI #10

Merged
merged 13 commits into from
Jun 25, 2023
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -45,9 +45,11 @@ RUN apt-get update -y \

# Copy code for command-line interface into image and install it
COPY . /root/Biosimulators_AMICI
RUN pip install /root/Biosimulators_AMICI \
RUN pip install pip==23.0.1
RUN pip install sympy /root/Biosimulators_AMICI \
&& rm -rf /root/Biosimulators_AMICI
RUN pip install amici==${SIMULATOR_VERSION}
#RUN pip install sympy /root/Biosimulators_AMICI amici==${SIMULATOR_VERSION} \
# && rm -rf /root/Biosimulators_AMICI
ENV VERBOSE=0 \
MPLBACKEND=PDF

Expand Down
15 changes: 12 additions & 3 deletions biosimulators_amici/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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}"
1 change: 0 additions & 1 deletion docs-src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion docs-src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pydata-sphinx-theme
sphinx >= 1.8
sphinxprettysearchresults
7 changes: 5 additions & 2 deletions tests/test_core_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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()