Skip to content

Commit

Permalink
Merge pull request #153 from biosimulators/reconcile-rbapy
Browse files Browse the repository at this point in the history
remove RBApy until it can be added back via PyPI
  • Loading branch information
jcschaff authored Sep 18, 2024
2 parents 6ff6945 + f0a39e2 commit c3219f0
Show file tree
Hide file tree
Showing 10 changed files with 458 additions and 498 deletions.
9 changes: 1 addition & 8 deletions .github/actions/setup-poetry-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@ runs:
run: poetry config virtualenvs.in-project true
shell: bash

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --with bngl,cellml,lems,neuroml,sbml,simularium,escher,containers,logging,rba,smoldyn
run: poetry install --no-interaction --with bngl,cellml,lems,neuroml,sbml,simularium,escher,containers,logging,smoldyn
shell: bash
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [ "3.10" ]
python-version: [ "3.10", "3.11" ]
fail-fast: false
defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion biosimulators_utils/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.189'
__version__ = '0.2.0'
610 changes: 284 additions & 326 deletions poetry.lock

Large diffs are not rendered by default.

29 changes: 14 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "biosimulators-utils"
version = "0.1.188"
version = "0.2.0"
description = "description"
license = "MIT"
authors = ["Center for Reproducible Biomedical Modeling <[email protected]>"]
Expand All @@ -21,7 +21,7 @@ include = [
]

[tool.poetry.dependencies]
python = "~3.10"
python = "^3.10"
appdirs = "*"
biopython = "*"
cement = "*"
Expand Down Expand Up @@ -58,7 +58,7 @@ pylems = {version = "*", optional = true}
pyneuroml = {version = ">=0.5.18", optional = true}
pint = {version = "*", optional = true}
libneuroml = {version = "*", optional = true}
rbapy = { git = "https://github.com/biosimulators/RBApy.git", rev="d82e1ade319cb503f6e28759a0cbeffccabd89e8", optional = true }
#rbapy = { git = "https://github.com/biosimulators/RBApy.git", rev="d82e1ade319cb503f6e28759a0cbeffccabd89e8", optional = true }
python-libsbml = {version = "*", optional = true}
smoldyn = {version = ">=2.66", optional = true}
simulariumio = {version = "*", optional = true}
Expand Down Expand Up @@ -111,18 +111,17 @@ dependencies = { pylems = "*", pyneuroml = "*", pint = "*" }
optional = true
dependencies = { libneuroml = "*", pyneuroml = ">=0.5.18" }

[tool.poetry.group.rba]
optional = true
# in requirements.optional.txt, rbapy was specified as:
#
# [rba]
# python -m pip install git+https://github.com/biosimulators/RBApy.git#egg=rbapy
#
dependencies = { rbapy = { git = "https://github.com/biosimulators/RBApy.git", rev="d82e1ade319cb503f6e28759a0cbeffccabd89e8" } }
#
# if using official release (not biosimulators fork), use:
# dependencies = { rbapy = "*" }

#[tool.poetry.group.rba]
#optional = true
## in requirements.optional.txt, rbapy was specified as:
##
## [rba]
## python -m pip install git+https://github.com/biosimulators/RBApy.git#egg=rbapy
##
# dependencies = { rbapy = { git = "https://github.com/biosimulators/RBApy.git", rev="d82e1ade319cb503f6e28759a0cbeffccabd89e8" } }
##
## if using official release (not biosimulators fork), use:
## dependencies = { rbapy = "*" }

[tool.poetry.group.sbml]
optional = true
Expand Down
151 changes: 76 additions & 75 deletions tests/model_lang/rba/test_rba_utils.py
Original file line number Diff line number Diff line change
@@ -1,79 +1,80 @@
from biosimulators_utils.model_lang.rba.utils import get_parameters_variables_outputs_for_simulation
from biosimulators_utils.sedml.data_model import SteadyStateSimulation
import math
import os
# from biosimulators_utils.model_lang.rba.utils import get_parameters_variables_outputs_for_simulation
# from biosimulators_utils.sedml.data_model import SteadyStateSimulation
# import math
# import os
import unittest


class RbaUtilsTestCase(unittest.TestCase):
FIXTURES_DIRNAME = os.path.join(os.path.dirname(__file__), '..', '..', 'fixtures', 'rba')

def test_get_parameters_variables_for_simulation(self):
filename = os.path.join(self.FIXTURES_DIRNAME, 'Escherichia-coli-K12-WT.zip')
params, sims, vars, plots = get_parameters_variables_outputs_for_simulation(filename, None, SteadyStateSimulation)

self.assertEqual(len(params), 1620)

param = next(param for param in params if param.id == 'parameter_amino_acid_concentration_Y_MIN')
self.assertEqual(param.name, 'Value of parameter "Y_MIN" of function "amino_acid_concentration"')
self.assertEqual(param.target, 'parameters.functions.amino_acid_concentration.parameters.Y_MIN')
self.assertEqual(param.new_value, '-inf')

self.assertEqual(len(sims), 1)
sim = sims[0]
self.assertIsInstance(sim, SteadyStateSimulation)
self.assertEqual(sim.algorithm.kisao_id, 'KISAO_0000669')
self.assertEqual(sim.algorithm.changes, [])

self.assertEqual(len(vars), 15766)

self.assertEqual(vars[0].id, 'objective')
self.assertEqual(vars[0].name, 'Value of objective')
self.assertEqual(vars[0].target, 'objective')

var = next(var for var in vars if var.id == 'M_pqq_p')
self.assertEqual(var.name, 'Dual of constraint "M_pqq_p"')
self.assertEqual(var.target, 'constraints.M_pqq_p')

var = next(var for var in vars if var.id == 'test_process_2_machinery')
self.assertEqual(var.name, 'Primal of variable "test_process_2_machinery"')
self.assertEqual(var.target, 'variables.test_process_2_machinery')

def test_get_parameters_variables_for_simulation_native_ids_data_types(self):
filename = os.path.join(self.FIXTURES_DIRNAME, 'Escherichia-coli-K12-WT.zip')
params, sims, vars, plots = get_parameters_variables_outputs_for_simulation(filename, None, SteadyStateSimulation, native_ids=True, native_data_types=True)

self.assertEqual(len(params), 1620)

param = next(param for param in params if param.id == 'amino_acid_concentration.Y_MIN')
self.assertEqual(param.name, None)
self.assertEqual(param.target, 'parameters.functions.amino_acid_concentration.parameters.Y_MIN')
self.assertEqual(param.new_value, -math.inf)

self.assertEqual(len(sims), 1)
sim = sims[0]
self.assertIsInstance(sim, SteadyStateSimulation)
self.assertEqual(sim.algorithm.kisao_id, 'KISAO_0000669')
self.assertEqual(sim.algorithm.changes, [])

self.assertEqual(len(vars), 15766)

self.assertEqual(vars[0].id, None)
self.assertEqual(vars[0].name, None)
self.assertEqual(vars[0].target, 'objective')

var = next(var for var in vars if var.id == 'M_pqq_p')
self.assertEqual(var.name, None)
self.assertEqual(var.target, 'constraints.M_pqq_p')

var = next(var for var in vars if var.id == 'test_process_2_machinery')
self.assertEqual(var.name, None)
self.assertEqual(var.target, 'variables.test_process_2_machinery')

def test_get_parameters_variables_for_simulation_error_handling(self):
with self.assertRaises(ValueError):
get_parameters_variables_outputs_for_simulation(None, None, None)

filename = os.path.join(self.FIXTURES_DIRNAME, 'Escherichia-coli-K12-WT.zip')
with self.assertRaises(NotImplementedError):
get_parameters_variables_outputs_for_simulation(filename, None, None)
pass
# FIXTURES_DIRNAME = os.path.join(os.path.dirname(__file__), '..', '..', 'fixtures', 'rba')

# def test_get_parameters_variables_for_simulation(self):
# filename = os.path.join(self.FIXTURES_DIRNAME, 'Escherichia-coli-K12-WT.zip')
# params, sims, vars, plots = get_parameters_variables_outputs_for_simulation(filename, None, SteadyStateSimulation)
#
# self.assertEqual(len(params), 1620)
#
# param = next(param for param in params if param.id == 'parameter_amino_acid_concentration_Y_MIN')
# self.assertEqual(param.name, 'Value of parameter "Y_MIN" of function "amino_acid_concentration"')
# self.assertEqual(param.target, 'parameters.functions.amino_acid_concentration.parameters.Y_MIN')
# self.assertEqual(param.new_value, '-inf')
#
# self.assertEqual(len(sims), 1)
# sim = sims[0]
# self.assertIsInstance(sim, SteadyStateSimulation)
# self.assertEqual(sim.algorithm.kisao_id, 'KISAO_0000669')
# self.assertEqual(sim.algorithm.changes, [])
#
# self.assertEqual(len(vars), 15766)
#
# self.assertEqual(vars[0].id, 'objective')
# self.assertEqual(vars[0].name, 'Value of objective')
# self.assertEqual(vars[0].target, 'objective')
#
# var = next(var for var in vars if var.id == 'M_pqq_p')
# self.assertEqual(var.name, 'Dual of constraint "M_pqq_p"')
# self.assertEqual(var.target, 'constraints.M_pqq_p')
#
# var = next(var for var in vars if var.id == 'test_process_2_machinery')
# self.assertEqual(var.name, 'Primal of variable "test_process_2_machinery"')
# self.assertEqual(var.target, 'variables.test_process_2_machinery')
#
# def test_get_parameters_variables_for_simulation_native_ids_data_types(self):
# filename = os.path.join(self.FIXTURES_DIRNAME, 'Escherichia-coli-K12-WT.zip')
# params, sims, vars, plots = get_parameters_variables_outputs_for_simulation(filename, None, SteadyStateSimulation, native_ids=True, native_data_types=True)
#
# self.assertEqual(len(params), 1620)
#
# param = next(param for param in params if param.id == 'amino_acid_concentration.Y_MIN')
# self.assertEqual(param.name, None)
# self.assertEqual(param.target, 'parameters.functions.amino_acid_concentration.parameters.Y_MIN')
# self.assertEqual(param.new_value, -math.inf)
#
# self.assertEqual(len(sims), 1)
# sim = sims[0]
# self.assertIsInstance(sim, SteadyStateSimulation)
# self.assertEqual(sim.algorithm.kisao_id, 'KISAO_0000669')
# self.assertEqual(sim.algorithm.changes, [])
#
# self.assertEqual(len(vars), 15766)
#
# self.assertEqual(vars[0].id, None)
# self.assertEqual(vars[0].name, None)
# self.assertEqual(vars[0].target, 'objective')
#
# var = next(var for var in vars if var.id == 'M_pqq_p')
# self.assertEqual(var.name, None)
# self.assertEqual(var.target, 'constraints.M_pqq_p')
#
# var = next(var for var in vars if var.id == 'test_process_2_machinery')
# self.assertEqual(var.name, None)
# self.assertEqual(var.target, 'variables.test_process_2_machinery')
#
# def test_get_parameters_variables_for_simulation_error_handling(self):
# with self.assertRaises(ValueError):
# get_parameters_variables_outputs_for_simulation(None, None, None)
#
# filename = os.path.join(self.FIXTURES_DIRNAME, 'Escherichia-coli-K12-WT.zip')
# with self.assertRaises(NotImplementedError):
# get_parameters_variables_outputs_for_simulation(filename, None, None)
71 changes: 36 additions & 35 deletions tests/model_lang/rba/test_rba_validation.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
from biosimulators_utils.model_lang.rba import validation
from biosimulators_utils.utils.core import flatten_nested_list_of_strings
import os
import rba
# from biosimulators_utils.model_lang.rba import validation
# from biosimulators_utils.utils.core import flatten_nested_list_of_strings
# import os
# import rba
import unittest


class RbaValidationTestCase(unittest.TestCase):
FIXTURE_DIRNAME = os.path.join(os.path.dirname(__file__), '..', '..', 'fixtures', 'rba')
pass
# FIXTURE_DIRNAME = os.path.join(os.path.dirname(__file__), '..', '..', 'fixtures', 'rba')

def test(self):
filename = os.path.join(self.FIXTURE_DIRNAME, 'Escherichia-coli-K12-WT.zip')
errors, warnings, model = validation.validate_model(filename)
self.assertEqual(errors, [])
self.assertEqual(warnings, [])
self.assertIsInstance(model, rba.model.RbaModel)

filename = None
errors, warnings, model = validation.validate_model(filename)
self.assertIn('is not a path', flatten_nested_list_of_strings(errors))
self.assertEqual(warnings, [])
self.assertEqual(model, None)

filename = os.path.join(self.FIXTURE_DIRNAME, 'not exist.zip')
errors, warnings, model = validation.validate_model(filename)
self.assertIn('does not exist', flatten_nested_list_of_strings(errors))
self.assertEqual(warnings, [])
self.assertEqual(model, None)

filename = __file__
errors, warnings, model = validation.validate_model(filename)
self.assertIn('is not a valid RBA', flatten_nested_list_of_strings(errors))
self.assertEqual(warnings, [])
self.assertEqual(model, None)

filename = os.path.join(self.FIXTURE_DIRNAME, 'Escherichia-coli-K12-WT-invalid.zip')
errors, warnings, model = validation.validate_model(filename)
self.assertIn('is not a valid RBA', flatten_nested_list_of_strings(errors))
self.assertEqual(warnings, [])
self.assertEqual(model, None)
# def test(self):
# filename = os.path.join(self.FIXTURE_DIRNAME, 'Escherichia-coli-K12-WT.zip')
# errors, warnings, model = validation.validate_model(filename)
# self.assertEqual(errors, [])
# self.assertEqual(warnings, [])
# self.assertIsInstance(model, rba.model.RbaModel)
#
# filename = None
# errors, warnings, model = validation.validate_model(filename)
# self.assertIn('is not a path', flatten_nested_list_of_strings(errors))
# self.assertEqual(warnings, [])
# self.assertEqual(model, None)
#
# filename = os.path.join(self.FIXTURE_DIRNAME, 'not exist.zip')
# errors, warnings, model = validation.validate_model(filename)
# self.assertIn('does not exist', flatten_nested_list_of_strings(errors))
# self.assertEqual(warnings, [])
# self.assertEqual(model, None)
#
# filename = __file__
# errors, warnings, model = validation.validate_model(filename)
# self.assertIn('is not a valid RBA', flatten_nested_list_of_strings(errors))
# self.assertEqual(warnings, [])
# self.assertEqual(model, None)
#
# filename = os.path.join(self.FIXTURE_DIRNAME, 'Escherichia-coli-K12-WT-invalid.zip')
# errors, warnings, model = validation.validate_model(filename)
# self.assertIn('is not a valid RBA', flatten_nested_list_of_strings(errors))
# self.assertEqual(warnings, [])
# self.assertEqual(model, None)
Loading

0 comments on commit c3219f0

Please sign in to comment.