Skip to content

Commit 86b077f

Browse files
authored
Merge pull request #63 from akutuva21/sympy
sympy: lazy import sympy + SBML getSize compatibility fix
2 parents 5766cdf + e3b7a2a commit 86b077f

42 files changed

Lines changed: 993 additions & 298 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
os: [ubuntu-latest, windows-latest, macos-latest]
24-
python-version: [3.7, 3.8]
24+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
2525
steps:
26-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v4
2727
with:
2828
fetch-depth: 0
2929
- name: Set up Python ${{ matrix.python-version }}
30-
uses: actions/setup-python@v2
30+
uses: actions/setup-python@v5
3131
with:
3232
python-version: ${{ matrix.python-version }}
3333
- name: Cache pip
34-
uses: actions/cache@v2
34+
uses: actions/cache@v4
3535
with:
3636
path: ~/.cache/pip
3737
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-dev.txt') }}
@@ -41,7 +41,7 @@ jobs:
4141
- name: Install dependencies
4242
run: |
4343
if [ "$RUNNER_OS" == "Linux" ]; then
44-
sudo apt-get -y install libncurses5-dev libncursesw5-dev libncurses5
44+
sudo apt-get update && sudo apt-get -y install libncurses-dev
4545
fi
4646
python -m pip install --upgrade pip
4747
pip install -r requirements-dev.txt
@@ -73,7 +73,7 @@ jobs:
7373
uses: docker/login-action@v2
7474
with:
7575
registry: ghcr.io
76-
username: ${{ secrets.GHCR_USER }}
76+
username: ${{ github.actor }}
7777
password: ${{ secrets.GITHUB_TOKEN }}
7878

7979
- name: Extract metadata (tags, labels) for Docker
@@ -86,7 +86,7 @@ jobs:
8686
uses: docker/build-push-action@v4.0.0
8787
with:
8888
context: .
89-
push: true
89+
push: ${{ github.event_name != 'pull_request' }}
9090
tags: ${{ steps.meta.outputs.tags }}
9191
labels: ${{ steps.meta.outputs.labels }}
9292

Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ LABEL org.opencontainers.image.source=https://github.com/RuleWorld/PyBioNetGen
66
LABEL org.opencontainers.image.description="PyBNG container"
77
LABEL org.opencontainers.image.licenses=MIT
88
RUN apt-get update && apt-get install -y \
9-
libncurses5-dev \
10-
libncursesw5-dev \
11-
libncurses5
9+
libncurses-dev
1210
WORKDIR /src
1311
COPY . /src
1412
RUN pip install --no-cache-dir -r requirements.txt
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import bionetgen
1+
import bionetgen
22

33
parameter = bionetgen.modelapi.structs.Parameter("A0", "10")
4-
print(parameter.gen_string())
4+
print(parameter.gen_string())

Issues/rule_keywords/run_pybng.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import bionetgen
22

3-
mname="test_deleteMolecules"
4-
model= bionetgen.bngmodel(mname+".bngl")
3+
mname = "test_deleteMolecules"
4+
model = bionetgen.bngmodel(mname + ".bngl")
55
print(model)

bionetgen/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,23 @@
22
from .modelapi import bngmodel
33
from .modelapi.runner import run
44
from .simulator import sim_getter
5+
6+
# sympy is an expensive dependency to import. We delay importing the
7+
# SympyOdes helpers until they are actually accessed.
8+
9+
__all__ = [
10+
"defaults",
11+
"bngmodel",
12+
"run",
13+
"sim_getter",
14+
"SympyOdes",
15+
"export_sympy_odes",
16+
]
17+
18+
19+
def __getattr__(name):
20+
if name in {"SympyOdes", "export_sympy_odes"}:
21+
from .modelapi.sympy_odes import SympyOdes, export_sympy_odes
22+
23+
return locals()[name]
24+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

bionetgen/atomizer/atomizeTool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from bionetgen.core.utils.logging import BNGLogger, log_level
66

7-
87
d = BNGDefaults()
98

109

bionetgen/atomizer/atomizer/analyzeSBML.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
import enum
9-
import imp
109
from pyparsing import Word, Suppress, Optional, alphanums, Group, ZeroOrMore
1110
import numpy as np
1211
import json
@@ -820,9 +819,9 @@ def loadConfigFiles(self, fileName):
820819
# deal with modifications
821820
if "modificationDefinition" in reactionDefinition_new:
822821
# TODO: Change file format to be nicer?
823-
reactionDefinition[
824-
"modificationDefinition"
825-
] = reactionDefinition_new["modificationDefinition"]
822+
reactionDefinition["modificationDefinition"] = (
823+
reactionDefinition_new["modificationDefinition"]
824+
)
826825
# convert new JSON format to old data format
827826
else:
828827
reactionDefinition["modificationDefinition"] = {}

bionetgen/atomizer/atomizer/atomizationAux.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44

55
class CycleError(Exception):
6-
76
"""Exception raised for errors in the input.
87
98
Attributes:

bionetgen/atomizer/atomizer/detectOntology.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
@author: proto
66
"""
7+
78
import pprint
89
import difflib
910
from collections import Counter

bionetgen/atomizer/atomizer/resolveSCT.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ def createSpeciesCompositionGraph(
113113
# lexicalDependencyGraph[element], oldDependency))
114114
"""
115115
if self.database.dependencyGraph[element] != []:
116-
self.database.alternativeDependencyGraph[
117-
element
118-
] = lexicalDependencyGraph[element]
116+
self.database.alternativeDependencyGraph[element] = (
117+
lexicalDependencyGraph[element]
118+
)
119119
else:
120120
logMess(
121121
"INFO:LAE009",
@@ -1464,9 +1464,9 @@ def selectBestCandidate(
14641464

14651465
tmpCandidates = namingTmpCandidates
14661466
if loginformation:
1467-
self.database.alternativeDependencyGraph[
1468-
reactant
1469-
] = tmpCandidates
1467+
self.database.alternativeDependencyGraph[reactant] = (
1468+
tmpCandidates
1469+
)
14701470
elif all(
14711471
sorted(x) == sorted(originalTmpCandidates[0])
14721472
for x in originalTmpCandidates
@@ -1568,9 +1568,9 @@ def selectBestCandidate(
15681568
namingTmpCandidates = tmpCandidates
15691569

15701570
else:
1571-
self.database.alternativeDependencyGraph[
1572-
reactant
1573-
] = namingtmpCandidates
1571+
self.database.alternativeDependencyGraph[reactant] = (
1572+
namingtmpCandidates
1573+
)
15741574
logMess(
15751575
"WARNING:SCT111",
15761576
"{0}:stoichiometry analysis:{1}:conflicts with and naming conventions:{2}:Selecting lexical analysis".format(

0 commit comments

Comments
 (0)