Skip to content

Commit

Permalink
Update AMICI to develop@8ef53c88 (#347)
Browse files Browse the repository at this point in the history
git subrepo clone --branch=develop --force [email protected]:AMICI-dev/AMICI.git deps/AMICI 

subrepo:
  subdir:   "deps/AMICI"
  merged:   "8ef53c88"
upstream:
  origin:   "[email protected]:AMICI-dev/AMICI.git"
  branch:   "develop"
  commit:   "8ef53c88"
git-subrepo:
  version:  "0.4.1"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "a04d8c2"
  • Loading branch information
dweindl committed Jul 13, 2021
1 parent 4bc174d commit b73a88f
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 50 deletions.
25 changes: 25 additions & 0 deletions deps/AMICI/.github/workflows/deploy_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,28 @@ jobs:
password: ${{ secrets.pypi_password }}
packages_dir: python/sdist/dist

bioSimulatorsUpdateCliAndDockerImage:
name: Release to BioSimulators
needs: pypi
runs-on: ubuntu-latest
env:
# Owner/repository-id for the GitHub repository for the downstream command-line interface and Docker image
DOWNSTREAM_REPOSITORY: biosimulators/Biosimulators_AMICI

# Username/token to use the GitHub API to trigger an action on the GitHub repository for the downstream
# command-line interface and Docker image. Tokens can be generated at https://github.com/settings/tokens.
# The token should have the scope `repo`
GH_ISSUE_USERNAME: ${{ secrets.BIOSIMULATORS_USERNAME }}
GH_ISSUE_TOKEN: ${{ secrets.BIOSIMULATORS_TOKEN }}
steps:
- name: Trigger GitHub action that will build and release the downstream command-line interface and Docker image
run: |
PACKAGE_VERSION="${GITHUB_REF/refs\/tags\/v/}"
WORKFLOW_FILE=ci.yml
curl \
-X POST \
-u ${GH_ISSUE_USERNAME}:${GH_ISSUE_TOKEN} \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${DOWNSTREAM_REPOSITORY}/actions/workflows/${WORKFLOW_FILE}/dispatches \
-d "{\"ref\": \"dev\", \"inputs\": {\"simulatorVersion\": \"${PACKAGE_VERSION}\", \"simulatorVersionLatest\": \"true\"}}"
32 changes: 0 additions & 32 deletions deps/AMICI/.github/workflows/release_biosimulators.yml

This file was deleted.

2 changes: 1 addition & 1 deletion deps/AMICI/.github/workflows/test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
python -m pip install --upgrade pip \
&& pip install pytest petab \
&& choco install -y ninja \
&& choco install -y swig --version=4.0.1
&& choco install -y swig
- name: Install OpenBLAS
shell: powershell
Expand Down
6 changes: 3 additions & 3 deletions deps/AMICI/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
;
[subrepo]
remote = [email protected]:ICB-DCM/AMICI.git
branch = v0.11.17
commit = c0377065207b68c881143d203de1f56fd52878b9
parent = d0bd8c19b9bb5426affdcd8386d893eee7940e80
branch = develop
commit = 8ef53c8808437cafc171d6ab9545a59d61bb83af
parent = eb33a10abde3faf2835ce846482817df06afcfe1
cmdver = 0.4.1
method = merge
23 changes: 22 additions & 1 deletion deps/AMICI/include/amici/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ namespace amici {
*/
class AmiException : public std::exception {
public:
/**
* @brief Constructor with printf style interface
* @param fmt error message with printf format
* @param ... printf formatting variables
*/
AmiException();

/**
* @brief Constructor with printf style interface
* @param fmt error message with printf format
Expand All @@ -40,6 +47,14 @@ class AmiException : public std::exception {
*/
void storeBacktrace(int nMaxFrames);

protected:
/**
* @brief Store the provided message
* @param fmt error message with printf format
* @param argptr pointer to variadic argument list
*/
void storeMessage(const char *fmt, va_list argptr);

private:
std::array<char, 500> msg_;
std::array<char, 500> trace_;
Expand Down Expand Up @@ -131,7 +146,13 @@ class IntegrationFailureB : public AmiException {
*/
class SetupFailure : public AmiException {
public:
using AmiException::AmiException;
/**
* @brief Constructor with printf style interface
* @param fmt error message with printf format
* @param ... printf formatting variables
*/
explicit SetupFailure(char const* fmt, ...);

};


Expand Down
15 changes: 13 additions & 2 deletions deps/AMICI/python/amici/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import re
import sys
from contextlib import suppress
from types import ModuleType
from types import ModuleType as ModelModule
from typing import Optional, Union, Sequence, List


Expand Down Expand Up @@ -134,6 +134,17 @@ def _imported_from_setup() -> bool:
from .sbml_import import SbmlImporter, assignmentRules2observables
from .ode_export import ODEModel, ODEExporter

try:
# Requires Python>=3.8
from typing import Protocol

class ModelModule(Protocol):
"""Enable Python static type checking for AMICI-generated model modules"""
def getModel(self) -> amici.Model:
pass
except ImportError:
pass

hdf5_enabled = 'readSolverSettingsFromHDF5' in dir()


Expand Down Expand Up @@ -283,7 +294,7 @@ def __exit__(self, exc_type, exc_value, traceback):


def import_model_module(module_name: str,
module_path: Optional[str] = None) -> ModuleType:
module_path: Optional[str] = None) -> ModelModule:
"""
Import Python module of an AMICI model
Expand Down
7 changes: 6 additions & 1 deletion deps/AMICI/python/amici/petab_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def import_model_sbml(
model_output_dir: Optional[str] = None,
verbose: Optional[Union[bool, int]] = True,
allow_reinit_fixpar_initcond: bool = True,
**kwargs) -> None:
**kwargs) -> amici.SbmlImporter:
"""
Create AMICI model from PEtab problem
Expand Down Expand Up @@ -415,6 +415,9 @@ def import_model_sbml(
:param kwargs:
Additional keyword arguments to be passed to
:meth:`amici.sbml_import.SbmlImporter.sbml2amici`.
:return:
The created :class:`amici.sbml_import.SbmlImporter` instance.
"""

set_log_level(logger, verbose)
Expand Down Expand Up @@ -584,6 +587,8 @@ def import_model_sbml(
verbose=verbose,
**kwargs)

return sbml_importer


# for backwards compatibility
import_model = import_model_sbml
Expand Down
21 changes: 16 additions & 5 deletions deps/AMICI/python/amici/petab_objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import numpy as np
import pandas as pd
import petab
import sympy as sp
from petab.C import * # noqa: F403

from . import AmiciModel, AmiciExpData
Expand Down Expand Up @@ -346,11 +347,21 @@ def _set_initial_concentration(condition_id, species_id, init_par_id,
value = petab.to_float_if_float(
petab_problem.condition_df.loc[condition_id, species_id])
if pd.isna(value):
value = float(
get_species_initial(
petab_problem.sbml_model.getSpecies(species_id)
)
value = get_species_initial(
petab_problem.sbml_model.getSpecies(species_id)
)
try:
value = float(value)
except ValueError:
if sp.nsimplify(value).is_Atom:
# Get rid of multiplication with one
value = sp.nsimplify(value)
else:
raise NotImplementedError(
"Cannot handle non-trivial expressions for "
f"species initial for {species_id}: {value}")
# this should be a parameter ID
value = str(value)
logger.debug(f'The species {species_id} has no initial value '
f'defined for the condition {condition_id} in '
'the PEtab conditions table. The initial value is '
Expand Down Expand Up @@ -728,4 +739,4 @@ def rdatas_to_simulation_df(
df = rdatas_to_measurement_df(rdatas=rdatas, model=model,
measurement_df=measurement_df)

return df.rename(columns={MEASUREMENT: SIMULATION})
return df.rename(columns={MEASUREMENT: SIMULATION})
7 changes: 5 additions & 2 deletions deps/AMICI/src/CMakeLists.template.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

include(CheckCXXCompilerFlag)
set(MY_CXX_FLAGS -Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable)
set(MY_CXX_FLAGS -Wall -Wno-unused-function -Wno-unused-variable)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
list(APPEND MY_CXX_FLAGS -Wno-unused-but-set-variable)
endif()
foreach(FLAG ${MY_CXX_FLAGS})
unset(CUR_FLAG_SUPPORTED CACHE)
CHECK_CXX_COMPILER_FLAG(${FLAG} CUR_FLAG_SUPPORTED)
CHECK_CXX_COMPILER_FLAG(-Werror ${FLAG} CUR_FLAG_SUPPORTED)
if(${CUR_FLAG_SUPPORTED})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
endif()
Expand Down
25 changes: 22 additions & 3 deletions deps/AMICI/src/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@

namespace amici {

AmiException::AmiException(const char *fmt, ...) {
AmiException::AmiException()
{
storeBacktrace(12);
}

AmiException::AmiException(const char *fmt, ...)
: AmiException()
{
va_list ap;
va_start(ap, fmt);
vsnprintf(msg_.data(), msg_.size(), fmt, ap);
storeMessage(fmt, ap);
va_end(ap);
storeBacktrace(12);
}

const char *AmiException::what() const noexcept {
Expand All @@ -29,6 +35,11 @@ void AmiException::storeBacktrace(const int nMaxFrames) {
backtraceString(nMaxFrames).c_str());
}

void AmiException::storeMessage(const char *fmt, va_list argptr)
{
vsnprintf(msg_.data(), msg_.size(), fmt, argptr);
}

CvodeException::CvodeException(const int error_code, const char *function) :
AmiException("Cvode routine %s failed with error code %i",function,error_code){}

Expand All @@ -48,4 +59,12 @@ NewtonFailure::NewtonFailure(int code, const char *function) :
error_code = code;
}

SetupFailure::SetupFailure(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
storeMessage(fmt, ap);
va_end(ap);
}

} // namespace amici

0 comments on commit b73a88f

Please sign in to comment.