Skip to content

Commit

Permalink
Merge pull request #65 from ModECI/development
Browse files Browse the repository at this point in the history
To v0.3.3; XML export & sbml, neuroml examples
  • Loading branch information
pgleeson authored Dec 14, 2023
2 parents e158706 + 490505e commit c67ef05
Show file tree
Hide file tree
Showing 47 changed files with 6,013 additions and 113 deletions.
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

0 comments on commit c67ef05

Please sign in to comment.