Skip to content

Commit c67ef05

Browse files
authored
Merge pull request #65 from ModECI/development
To v0.3.3; XML export & sbml, neuroml examples
2 parents e158706 + 490505e commit c67ef05

Some content is hidden

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

47 files changed

+6013
-113
lines changed

.github/workflows/ci.yml

+15-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
python-version: [ "3.7", "3.8", "3.9", "3.10"]
27+
python-version: [ "3.8", "3.9", "3.10", "3.11"]
2828
runs-on: [ubuntu-latest, macos-latest, windows-latest]
2929

3030
steps:
@@ -34,6 +34,7 @@ jobs:
3434
with:
3535
python-version: ${{ matrix.python-version }}
3636

37+
3738
- name: Install package
3839
run: |
3940
python -m pip install --upgrade pip
@@ -47,24 +48,33 @@ jobs:
4748
run: |
4849
pip list
4950
50-
- name: Run some examples
51+
- name: Run simple examples
5152
run: |
5253
cd examples
5354
python document.py
5455
5556
cd test
5657
python test.py
5758
58-
## Test NeuroML example
59+
- name: Test NeuroML examples
60+
if: ${{ matrix.python-version != '3.7'}}
61+
run: |
5962
60-
cd ../neuroml2
63+
cd examples/neuroml2
6164
python neuroml2_spec.py
6265
6366
# Note: NeuroML files will be validated with OMV below
6467
68+
- name: Test SBML examples
69+
if: ${{ matrix.python-version != '3.7'}}
70+
run: |
71+
72+
cd examples/sbml
73+
./regenerateAndTest.sh
74+
6575
- name: Run pytest
6676
run: |
67-
pytest tests
77+
pytest tests -v
6878
6979
- name: Install & test NeuroMLlite
7080
run: |

.github/workflows/static.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
uses: actions/checkout@v3
3434

3535
- name: Set up Python
36-
uses: actions/setup-python@v2
36+
uses: actions/setup-python@v4
3737
with:
3838
python-version: 3.9
3939

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,4 @@ cython_debug/
163163
.idea/
164164
/examples/document.specification.bson
165165
/examples/neuroml2/hello_world.v.dat
166+
/examples/sbml/example_sbml_test.xml

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Modelspec
22

3-
43
[![Continuous builds](https://github.com/ModECI/modelspec/actions/workflows/ci.yml/badge.svg)](https://github.com/ModECI/modelspec/actions/workflows/ci.yml) [![PyPI](https://img.shields.io/pypi/v/modelspec)](https://pypi.org/project/modelspec/)
54

6-
7-
Functionality for specifying the structure of models & enabling automatic serialization to them (e.g. in JSON and YAML format).
5+
Functionality for specifying the allowed structure of models, facilitating the creation of APIs in Python for handling the models & enabling automatic serialization of instances of them (e.g. in JSON and YAML format).
86

97
This package is being used by [NeuroMLlite](https://github.com/NeuroML/NeuroMLlite) & [MDF](https://github.com/ModECI/MDF).
108

docs/sphinx/source/api/Contributors.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Modelspec contributors
44

55
This page list names and Github profiles of contributors to Modelspec, listed in no particular order.
6-
This page is generated periodically, most recently on 2023-09-12.
6+
This page is generated periodically, most recently on 2023-12-13.
77

88
- Padraig Gleeson ([@pgleeson](https://github.com/pgleeson))
99
- Manifest Chakalov ([@mqnifestkelvin](https://github.com/mqnifestkelvin))

docs/sphinx/source/api/Introduction.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Modelspec
22

3-
43
[![Continuous builds](https://github.com/ModECI/modelspec/actions/workflows/ci.yml/badge.svg)](https://github.com/ModECI/modelspec/actions/workflows/ci.yml) [![PyPI](https://img.shields.io/pypi/v/modelspec)](https://pypi.org/project/modelspec/)
54

6-
7-
Functionality for specifying the structure of models & enabling automatic serialization to them (e.g. in JSON and YAML format).
5+
Functionality for specifying the allowed structure of models, facilitating the creation of APIs in Python for handling the models & enabling automatic serialization of instances of them (e.g. in JSON and YAML format).
86

97
This package is being used by [NeuroMLlite](https://github.com/NeuroML/NeuroMLlite) & [MDF](https://github.com/ModECI/MDF).
108

docs/sphinx/source/api/Quickstart.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@ More details, and importantly, how to set up a [virtual environment](https://vir
1515

1616
### Simple example
1717

18-
A basic example which illustrates how to create the specification for a document(model) and create serialized instances can be found [here](examples/README).
18+
A basic example which illustrates how to create the specification for a document (i.e. the model definition for a document) and create serialized instances can be found [here](examples/README).
1919

2020
### Serialization formats
2121

22-
Python scripts can be used to generate the specification of a type of model(e.g. [this](https://github.com/ModECI/modelspec/blob/main/examples/document.py)), but the models are saved in standardized format in either text based [JSON](https://github.com/ModECI/modelspec/blob/main/examples/document.json) or [YAML](https://github.com/ModECI/modelspec/blob/main/examples/document.yaml) formats or in binary [BSON](https://github.com/ModECI/modelspec/blob/main/examples/document.bson) format. Support for XML serialization is under development.
22+
Python scripts can be used to generate the specification of a type of model (e.g. [this](https://github.com/ModECI/modelspec/blob/main/examples/document.py)), but the models are saved in standardized format in either text based ([JSON](https://github.com/ModECI/modelspec/blob/main/examples/document.json) or [YAML](https://github.com/ModECI/modelspec/blob/main/examples/document.yaml)) formats or in binary ([BSON](https://github.com/ModECI/modelspec/blob/main/examples/document.bson)) format. Support for [XML](https://github.com/ModECI/modelspec/blob/main/examples/document.xml) serialization has recently been added.
2323

2424
### Current formats using modelspec
2525

26-
#### MDF
26+
#### MDF (Model Description Format)
2727

28-
MDF uses modelspec to create the structure of its models and convert the models into serialized formats such as JSON, YAML, and BSON.
28+
[ModECI's MDF](https://modeci.org/quickstart) uses modelspec to create the structure of its models and convert the models into serialized formats such as JSON, YAML, and BSON.
2929

3030
#### NeuroML
3131

32-
NeuroMLlite uses modelspec to create the structure of its models and convert the models into serialize formats such as JSON, YAML, and BSON.
32+
[NeuroMLlite](https://github.com/NeuroML/NeuroMLlite) uses modelspec to create the structure of its models and convert the models into serialize formats such as JSON, YAML, and BSON.
33+
The XML serialisation of modelspec will be useful for integrating NeuroML 2 files into the framework, see [here](https://github.com/ModECI/modelspec/tree/main/examples/neuroml2).
10 Bytes
Binary file not shown.

docs/sphinx/source/api/examples/document.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"MyBook": {
33
"title": "My life in Python",
4+
"ISBN": 123,
45
"sections": {
56
"Abstract": {
67
"paragraphs": [

docs/sphinx/source/api/examples/document.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Document(Base):
5252
sections: List[Section] = field(factory=list)
5353

5454

55-
doc = Document(id="MyBook")
55+
doc = Document(id="MyBook", ISBN=123)
5656
doc.title = "My life in Python"
5757

5858
a = Section(id="Abstract")

docs/sphinx/source/api/examples/document.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<?xml version="1.0" ?>
2-
<Document id="MyBook" title="My life in Python" ISBN="None">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Document id="MyBook" title="My life in Python" ISBN="123">
33
<Section id="Abstract">
44
<Paragraph contents="Blah blah blah"/>
55
<Paragraph contents="Blah2"/>

docs/sphinx/source/api/examples/document.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
MyBook:
22
title: My life in Python
3+
ISBN: 123
34
sections:
45
Abstract:
56
paragraphs:

examples/COMBINE.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# COMBINE standards in modelspec
2+
3+
![combine](images/combine.png)
4+
5+
To illustrate the utility of modelspec, and to create a uniform, compatible set of APIs across a diverse range of model specification formats, we are investigating the [COMBINE set of standards in computational biology](https://co.mbine.org/standards/), and attempting to express these formats in modelspec.
6+
7+
## NeuroML
8+
9+
![neuroml](images/neuroml.png)
10+
11+
A preliminary version of an API for [NeuroML2](https://docs.neuroml.org/Userdocs/NeuroMLv2.html) can be found [here](neuroml2). This allows generation of NeuroML2 models using the modelspec based API, saving as valid XML, as well as JSON, YAML and BSON equivalents. See [neuroml2_spec.py](neuroml2/neuroml2_spec.py).
12+
13+
[NeuroMLlite](https://github.com/NeuroML/NeuroMLlite) already uses modelspec as its primary specification format. See [here](https://github.com/NeuroML/NeuroMLlite/blob/master/neuromllite/__init__.py).
14+
15+
## SBML
16+
17+
![combine](images/sbml.png)
18+
19+
Work towards an API for [SBML](https://www.sbml.org/) can be found [here](sbml).
20+
21+
An example of an SBML file generated from this is [here](sbml/test_minimal_example.xml).
22+
23+
## CellML
24+
25+
TODO...
26+
27+
## SED-ML
28+
29+
TODO...

examples/document.bson

10 Bytes
Binary file not shown.

examples/document.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"MyBook": {
33
"title": "My life in Python",
4+
"ISBN": 123,
45
"sections": {
56
"Abstract": {
67
"paragraphs": [

examples/document.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Document(Base):
5252
sections: List[Section] = field(factory=list)
5353

5454

55-
doc = Document(id="MyBook")
55+
doc = Document(id="MyBook", ISBN=123)
5656
doc.title = "My life in Python"
5757

5858
a = Section(id="Abstract")

examples/document.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<?xml version="1.0" ?>
2-
<Document id="MyBook" title="My life in Python" ISBN="None">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Document id="MyBook" title="My life in Python" ISBN="123">
33
<Section id="Abstract">
44
<Paragraph contents="Blah blah blah"/>
55
<Paragraph contents="Blah2"/>

examples/document.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
MyBook:
22
title: My life in Python
3+
ISBN: 123
34
sections:
45
Abstract:
56
paragraphs:

examples/images/combine.png

165 KB
Loading

examples/images/neuroml.png

3.8 KB
Loading

examples/images/sbml.png

17.9 KB
Loading

examples/neuroml2/TestNeuroML.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" ?>
1+
<?xml version="1.0" encoding="UTF-8"?>
22
<neuroml xmlns="http://www.neuroml.org/schema/neuroml2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="TestNeuroML" xsi:schemaLocation="http://www.neuroml.org/schema/neuroml2 https://raw.github.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.3.xsd">
33
<izhikevich2007Cell id="izh2007RS0" C="100pF" v0="-60mV" k="0.7nS_per_mV" vr="-60mV" vt="-40mV" vpeak="35mV" a="0.03per_ms" b="-2nS" c="-50.0mV" d="100pA"/>
44
<pulseGenerator id="pulseGen_0" delay="100ms" duration="800ms" amplitude="0.07 nA"/>

examples/neuroml2/neuroml2_spec.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class neuroml(Base):
197197

198198
with open("NeuroML2.specification.yaml", "w") as d:
199199
yy = yaml.dump(doc_dict, indent=4, sort_keys=False)
200-
print(yy)
200+
# print(yy)
201201
d.write(yy)
202202

203203
from modelspec.utils import load_xml

0 commit comments

Comments
 (0)