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

To v0.3.3; XML export & sbml, neuroml examples #65

Merged
merged 49 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
d3c302e
Install hdf5 from source
pgleeson Jan 12, 2023
f49bb88
install libhdf5-dev
pgleeson Jan 12, 2023
ad4df19
sudo
pgleeson Jan 12, 2023
f25194c
Update ci.yml
pgleeson Jan 31, 2023
268e72a
Merge branch 'development' into experimental
pgleeson Jun 12, 2023
9770a5a
ci(py311): add to matrix
sanjayankur31 Jul 26, 2023
7573d9e
Merge branch 'development' into experimental
pgleeson Jul 27, 2023
2b92351
added simple sbml test with example xml showing desired output we sho…
robertvi Jul 29, 2023
920aef0
Merge pull request #53 from robertvi/test_xml3
pgleeson Jul 31, 2023
f0f8e6c
Formatted new sbml files
pgleeson Jul 31, 2023
49d9fc6
Test 3.11
pgleeson Aug 8, 2023
aede680
Merge pull request #55 from ModECI/test_xml3
pgleeson Aug 15, 2023
e82058b
Merge branch 'development' into test_sbml
pgleeson Aug 23, 2023
c6e70f8
Add comment
pgleeson Sep 6, 2023
57615ec
Merge branch 'main' into test_neuroml
pgleeson Sep 13, 2023
9d3ffa9
Update gha version
pgleeson Sep 13, 2023
d03ffb2
Bump version to v0.3.3
pgleeson Sep 13, 2023
c304185
Merge branch 'test_neuroml' into test_sbml
pgleeson Sep 13, 2023
2964ff4
Some doc updates
pgleeson Sep 13, 2023
035c405
Merge branch 'test_neuroml' into test_sbml
pgleeson Sep 13, 2023
c20f2f2
Merge pull request #61 from ModECI/test_neuroml
pgleeson Sep 15, 2023
b865e16
Merge branch 'development' into test_sbml
pgleeson Sep 15, 2023
18ea90b
Update testing on save/load json/yaml
pgleeson Sep 18, 2023
d65bc18
Minimal working sbml example
pgleeson Sep 18, 2023
af43a93
Updates to core sbml model definition
pgleeson Sep 18, 2023
5c1eba6
Don't test xml examples on py3.7
pgleeson Sep 18, 2023
53c86e9
Update ci.yml
pgleeson Sep 18, 2023
f5c7445
Add sbml requirements
pgleeson Sep 18, 2023
5b2a2f7
Merge branch 'test_sbml' of github.com:ModECI/modelspec into test_sbml
pgleeson Sep 18, 2023
fe6b3ae
Merge pull request #51 from sanjayankur31/feat/3.11
pgleeson Sep 18, 2023
c2317e5
Merge pull request #63 from ModECI/test_neuroml
pgleeson Sep 18, 2023
1064af3
Generates same example sbml; restructured handling of listOf... classes
pgleeson Sep 18, 2023
c77b629
Merge branch 'development' into test_sbml
pgleeson Sep 18, 2023
757a450
Generate spec docs for sbml
pgleeson Sep 19, 2023
37a9da1
Update COMBINE specs docs
pgleeson Sep 19, 2023
02de41a
Merge pull request #64 from ModECI/test_sbml
pgleeson Sep 19, 2023
c3000df
Regenerated
pgleeson Nov 8, 2023
5f6b50d
Add isbn to doc
pgleeson Nov 8, 2023
309eecb
Add pandas requirement for docs
pgleeson Nov 8, 2023
5b96714
Tweak
pgleeson Nov 22, 2023
dbb3222
Pin cattrs to test if that's the issue...
pgleeson Nov 22, 2023
b8b1f66
Update setup.cfg
pgleeson Nov 23, 2023
50c54c5
Add 3.11 as supported env
pgleeson Dec 13, 2023
3386d4a
Merge branch 'development' into experimental
pgleeson Dec 13, 2023
6216251
Test unpin cattrs
pgleeson Dec 13, 2023
8e93394
More specific version...
pgleeson Dec 13, 2023
1f6db92
Remove 3.7 support...
pgleeson Dec 13, 2023
386fa23
h5py install not required
pgleeson Dec 13, 2023
490505e
Merge pull request #69 from ModECI/experimental
pgleeson Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.7", "3.8", "3.9", "3.10"]
python-version: [ "3.8", "3.9", "3.10", "3.11"]
runs-on: [ubuntu-latest, macos-latest, windows-latest]

steps:
Expand All @@ -34,6 +34,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}


- name: Install package
run: |
python -m pip install --upgrade pip
Expand All @@ -47,24 +48,33 @@ jobs:
run: |
pip list

- name: Run some examples
- name: Run simple examples
run: |
cd examples
python document.py

cd test
python test.py

## Test NeuroML example
- name: Test NeuroML examples
if: ${{ matrix.python-version != '3.7'}}
run: |

cd ../neuroml2
cd examples/neuroml2
python neuroml2_spec.py

# Note: NeuroML files will be validated with OMV below

- name: Test SBML examples
if: ${{ matrix.python-version != '3.7'}}
run: |

cd examples/sbml
./regenerateAndTest.sh

- name: Run pytest
run: |
pytest tests
pytest tests -v

- name: Install & test NeuroMLlite
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.9

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,4 @@ cython_debug/
.idea/
/examples/document.specification.bson
/examples/neuroml2/hello_world.v.dat
/examples/sbml/example_sbml_test.xml
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Modelspec


[![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/)


Functionality for specifying the structure of models & enabling automatic serialization to them (e.g. in JSON and YAML format).
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).

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

Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx/source/api/Contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Modelspec contributors

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

- Padraig Gleeson ([@pgleeson](https://github.com/pgleeson))
- Manifest Chakalov ([@mqnifestkelvin](https://github.com/mqnifestkelvin))
Expand Down
4 changes: 1 addition & 3 deletions docs/sphinx/source/api/Introduction.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Modelspec


[![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/)


Functionality for specifying the structure of models & enabling automatic serialization to them (e.g. in JSON and YAML format).
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).

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

Expand Down
11 changes: 6 additions & 5 deletions docs/sphinx/source/api/Quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ More details, and importantly, how to set up a [virtual environment](https://vir

### Simple example

A basic example which illustrates how to create the specification for a document(model) and create serialized instances can be found [here](examples/README).
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).

### Serialization formats

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.
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.

### Current formats using modelspec

#### MDF
#### MDF (Model Description Format)

MDF uses modelspec to create the structure of its models and convert the models into serialized formats such as JSON, YAML, and BSON.
[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.

#### NeuroML

NeuroMLlite uses modelspec to create the structure of its models and convert the models into serialize formats such as JSON, YAML, and BSON.
[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.
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).
Binary file modified docs/sphinx/source/api/examples/document.bson
Binary file not shown.
1 change: 1 addition & 0 deletions docs/sphinx/source/api/examples/document.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"MyBook": {
"title": "My life in Python",
"ISBN": 123,
"sections": {
"Abstract": {
"paragraphs": [
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx/source/api/examples/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Document(Base):
sections: List[Section] = field(factory=list)


doc = Document(id="MyBook")
doc = Document(id="MyBook", ISBN=123)
doc.title = "My life in Python"

a = Section(id="Abstract")
Expand Down
4 changes: 2 additions & 2 deletions docs/sphinx/source/api/examples/document.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<Document id="MyBook" title="My life in Python" ISBN="None">
<?xml version="1.0" encoding="UTF-8"?>
<Document id="MyBook" title="My life in Python" ISBN="123">
<Section id="Abstract">
<Paragraph contents="Blah blah blah"/>
<Paragraph contents="Blah2"/>
Expand Down
1 change: 1 addition & 0 deletions docs/sphinx/source/api/examples/document.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MyBook:
title: My life in Python
ISBN: 123
sections:
Abstract:
paragraphs:
Expand Down
29 changes: 29 additions & 0 deletions examples/COMBINE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# COMBINE standards in modelspec

![combine](images/combine.png)

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.

## NeuroML

![neuroml](images/neuroml.png)

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).

[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).

## SBML

![combine](images/sbml.png)

Work towards an API for [SBML](https://www.sbml.org/) can be found [here](sbml).

An example of an SBML file generated from this is [here](sbml/test_minimal_example.xml).

## CellML

TODO...

## SED-ML

TODO...
Binary file modified examples/document.bson
Binary file not shown.
1 change: 1 addition & 0 deletions examples/document.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"MyBook": {
"title": "My life in Python",
"ISBN": 123,
"sections": {
"Abstract": {
"paragraphs": [
Expand Down
2 changes: 1 addition & 1 deletion examples/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Document(Base):
sections: List[Section] = field(factory=list)


doc = Document(id="MyBook")
doc = Document(id="MyBook", ISBN=123)
doc.title = "My life in Python"

a = Section(id="Abstract")
Expand Down
4 changes: 2 additions & 2 deletions examples/document.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
<Document id="MyBook" title="My life in Python" ISBN="None">
<?xml version="1.0" encoding="UTF-8"?>
<Document id="MyBook" title="My life in Python" ISBN="123">
<Section id="Abstract">
<Paragraph contents="Blah blah blah"/>
<Paragraph contents="Blah2"/>
Expand Down
1 change: 1 addition & 0 deletions examples/document.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MyBook:
title: My life in Python
ISBN: 123
sections:
Abstract:
paragraphs:
Expand Down
Binary file added examples/images/combine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/neuroml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/images/sbml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/neuroml2/TestNeuroML.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" ?>
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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"/>
<pulseGenerator id="pulseGen_0" delay="100ms" duration="800ms" amplitude="0.07 nA"/>
Expand Down
2 changes: 1 addition & 1 deletion examples/neuroml2/neuroml2_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class neuroml(Base):

with open("NeuroML2.specification.yaml", "w") as d:
yy = yaml.dump(doc_dict, indent=4, sort_keys=False)
print(yy)
# print(yy)
d.write(yy)

from modelspec.utils import load_xml
Expand Down
Loading
Loading