Skip to content

Commit

Permalink
Merge pull request #37 from NeuroML/development
Browse files Browse the repository at this point in the history
Updates for v2.3
  • Loading branch information
pgleeson authored Sep 20, 2023
2 parents 981e8b6 + 3639254 commit fe071d7
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 38 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,69 +15,71 @@ jobs:
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
java: [ '8', '11', '16', '17' ]
runs-on: [ubuntu-latest, macos-11, windows-latest]
matrix:
java: [ '8', '11', '16', '17', '19' ]
runs-on: [ubuntu-latest, macos-latest, windows-latest]

name: Test on Java ${{ matrix.Java }} on ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.Java }}
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.Java }}
distribution: 'temurin'

- name: Install and test (non Win)
env:
main_repo_branch: ${GITHUB_REF_NAME}
if: ${{ matrix.runs-on != 'windows-latest' }}
run: |
# Install org.neuroml.model.injectingplugin
export main_repo_branch=${{env.main_repo_branch}}
if [[ ${main_repo_branch} != "master" && ${main_repo_branch} != "development" && ${main_repo_branch} != "experimental" && ${main_repo_branch} != *"osb"* ]]; then main_repo_branch=development ; fi
echo Using branch $main_repo_branch
git clone https://github.com/NeuroML/org.neuroml.model.injectingplugin.git
cd org.neuroml.model.injectingplugin
git checkout $main_repo_branch
mvn install
cd ..
# Install NeuroML2
git clone https://github.com/NeuroML/NeuroML2.git
cd NeuroML2
git checkout $main_repo_branch
mvn install
cd ..
# Install this package and test with Maven
pwd
mvn install
mvn dependency:tree
- name: Install and test (Win)
if: ${{ matrix.runs-on == 'windows-latest' }}
run: |
# Install org.neuroml.model.injectingplugin
$env:main_repo_branch=$env:GITHUB_REF_NAME
if ( $env:main_repo_branch -ne "master" -and $env:main_repo_branch -ne "development" -and $env:main_repo_branch -ne "experimental" -and $env:main_repo_branch -notlike '*osb*' ) { $env:main_repo_branch="development" }
echo "Using branch $env:main_repo_branch..."
git clone https://github.com/NeuroML/org.neuroml.model.injectingplugin.git
cd org.neuroml.model.injectingplugin
git checkout $env:main_repo_branch
mvn install
cd ..
# Install NeuroML2
echo Using branch $env:GITHUB_REF_NAME
git clone https://github.com/NeuroML/NeuroML2.git
cd NeuroML2
git checkout $env:main_repo_branch
mvn install
cd ..
# Install this package and test with Maven
pwd
mvn install
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/javadocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish javadocs

on:
push:
branches: [ development ]
branches: [ development, experimental ]

jobs:
build:
Expand All @@ -11,10 +11,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
java-package: jdk

- name: Set up Python 3.9
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ NeuroML v2 Model Java API
=========================

[![Java CI with Maven](https://github.com/NeuroML/org.neuroml.model/actions/workflows/ci.yml/badge.svg)](https://github.com/NeuroML/org.neuroml.model/actions/workflows/ci.yml)
[![pages-build-deployment](https://github.com/NeuroML/org.neuroml.model/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/NeuroML/org.neuroml.model/actions/workflows/pages/pages-build-deployment)
[![Publish javadocs](https://github.com/NeuroML/org.neuroml.model/actions/workflows/javadocs.yml/badge.svg)](https://github.com/NeuroML/org.neuroml.model/actions/workflows/javadocs.yml)

[![GitHub](https://img.shields.io/github/license/NeuroML/org.neuroml.model)](https://github.com/NeuroML/org.neuroml.model/blob/master/LICENSE.lesser)
[![GitHub pull requests](https://img.shields.io/github/issues-pr/NeuroML/org.neuroml.model)](https://github.com/NeuroML/org.neuroml.model/pulls)
[![GitHub issues](https://img.shields.io/github/issues/NeuroML/org.neuroml.model)](https://github.com/NeuroML/org.neuroml.model/issues)
Expand All @@ -23,4 +26,6 @@ A collection of models in NeuroML can be found on the [Open Source Brain](http:/

This code is distributed under the terms of the GNU Lesser General Public License.

API documentation can be found [here](http://neuroml.github.io/org.neuroml.model/index.html).
API documentation can be found [here](http://neuroml.github.io/org.neuroml.model/index.html).


14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.neuroml.model</groupId>
<artifactId>org.neuroml.model</artifactId>
<version>1.8.1</version>
<version>1.9.1</version>
<packaging>bundle</packaging>
<properties>
<build.version2>2.1</build.version2>
<build.version2>2.3</build.version2>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
Expand All @@ -19,12 +19,12 @@
<dependency>
<groupId>org.neuroml.model.injectingplugin</groupId>
<artifactId>org.neuroml.model.injectingplugin</artifactId>
<version>1.8.1</version>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.neuroml.core</groupId>
<artifactId>neuroml2-base-definitions</artifactId>
<version>1.8.1</version>
<version>1.9.1</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -64,7 +64,7 @@
&lt;br /&gt;
&lt;br /&gt;
</top>
<bottom>Copyright NeuroML Contributors 2021</bottom>
<bottom>Copyright NeuroML Contributors 2022</bottom>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -105,7 +105,7 @@
</goals>
<configuration>
<resourceBundles>
<resourcebundle>org.neuroml.core:neuroml2-base-definitions:1.8.1</resourcebundle>
<resourcebundle>org.neuroml.core:neuroml2-base-definitions:1.9.1</resourcebundle>
</resourceBundles>
</configuration>
</execution>
Expand Down Expand Up @@ -198,7 +198,7 @@
<plugin>
<groupId>org.neuroml.model.injectingplugin</groupId>
<artifactId>org.neuroml.model.injectingplugin</artifactId>
<version>1.8.1</version>
<version>1.9.1</version>
</plugin>
</plugins>
</configuration>
Expand Down
33 changes: 29 additions & 4 deletions src/main/java/org/neuroml/model/util/NeuroML2Validator.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
import org.xml.sax.SAXException;

/*
*
* WORK IN PROGRESS!!!
*
* TODO: Needs to be moved to a separate package for validation!
*/
Expand Down Expand Up @@ -488,7 +486,33 @@ public void testValidityAgainstNeuroML2Schema(File xmlFile) throws SAXException,
testValidity(xmlFile, new StreamSource(in));
validity.append(VALID_AGAINST_SCHEMA);
} catch (Exception e) {
validity.append("File: "+ xmlFile.getAbsolutePath()+" is not valid against the schema: "+NeuroMLElements.LATEST_SCHEMA+"!!\n"+e.getMessage());
String error = e.getMessage();

StringBuilder formatted = new StringBuilder(" Error when parsing against Schema ("+e.getClass()+"): \n\n ");

String indent = new String(" ");
for (int i=0; i<error.length(); i++) {
char c = error.charAt(i);
formatted.append(c);
if (c==';') {formatted.append("\n"+indent);}
if (c=='.' && i<error.length()-1 && error.charAt(i+1)==' ') {formatted.append("\n"+indent); i+=1;}
}

validity.append("File: "+ xmlFile.getAbsolutePath()+" is not valid against the schema: "+NeuroMLElements.LATEST_SCHEMA+"!!\n"+formatted);

if (error.indexOf("is not allowed to appear in element")>0) {
validity.append("\n\n Please check which attributes are allowed in that NeuroML element");
}
if (error.indexOf("end-tag")>0) {
validity.append("\n\n Please make sure the XML is formatted correctly");
}
if (error.indexOf("cvc-complex-type.2.4")>=0) {
validity.append("\n\n Note 1: if the above mentioned element is not a part of the core NeuroML elements, then the document can't be validated against the Schema. This may not matter if a definition in LEMS is available for that element (e.g. a new ComponentType has been defined and included) and the model should be able to run in simulators that support new LEMS elements."
+ "\n\n Note 2: If the element giving trouble is a core NeuroML element, remember that when validating with the NeuroML Schema, the order of the elements is important. Try switching the order of the above mentioned elements in line with how they are defined in the Schema, keeping elements of the same type together.");
}



}
}

Expand All @@ -515,11 +539,12 @@ public static void testValidity(File xmlFile, StreamSource schemaFileSource) thr


public static void main(String[] args) throws Exception {
File f = new File("../neuroConstruct/osb/showcase/BlueBrainProjectShowcase/NMC/NeuroML2/CaDynamics_E2_NML2.nml");
//File f = new File("../neuroConstruct/osb/cerebral_cortex/networks/ACnet2/neuroConstruct/generatedNeuroML2/pyr_4_sym.cell.nml");
//File f = new File("../neuroConstruct/osb/cerebral_cortex/networks/ACnet2/neuroConstruct/generatedNeuroML2/MediumNet.net.nml");
//File f = new File("../OpenCortex/examples/Deterministic.net.nml");
//File f = new File("../neuroConstruct/osb/cerebellum/cerebellar_granule_cell/GranuleCell/neuroConstruct/generatedNeuroML2/GranuleCell.net.nml");
File f = new File("../git/Documentation/source/Userdocs/NML2_examples/olm.cell.nml");
//File f = new File("../git/Documentation/source/Userdocs/NML2_examples/olm.cell.nml");


NeuroML2Validator nv = new NeuroML2Validator();
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/neuroml/model/util/NeuroMLElements.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class NeuroMLElements {

public static final String ORG_NEUROML_MODEL_VERSION = "1.8.1";
public static final String ORG_NEUROML_MODEL_VERSION = "1.9.1";

public static final String NAMESPACE_URI_VERSION_2 = "http://www.neuroml.org/schema/neuroml2";

Expand All @@ -16,10 +16,12 @@ public class NeuroMLElements {
public static final String DEFAULT_SCHEMA_LOCATION_VERSION_2_0 = "https://raw.githubusercontent.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.0.xsd";
public static final String DEFAULT_SCHEMA_LOCATION_VERSION_2_1 = "https://raw.githubusercontent.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.1.xsd";
public static final String DEFAULT_SCHEMA_LOCATION_VERSION_2_2 = "https://raw.githubusercontent.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.2.xsd";
public static final String DEFAULT_SCHEMA_LOCATION_VERSION_2_3 = "https://raw.githubusercontent.com/NeuroML/NeuroML2/development/Schemas/NeuroML2/NeuroML_v2.3.xsd";


public static final String LATEST_SCHEMA = "/Schemas/NeuroML2/NeuroML_v2.2.xsd";
public static final String LATEST_SCHEMA_LOCATION = DEFAULT_SCHEMA_LOCATION_VERSION_2_2;
public static final String LATEST_SCHEMA_VERSION = "2.3";
public static final String LATEST_SCHEMA = "/Schemas/NeuroML2/NeuroML_v"+LATEST_SCHEMA_VERSION+".xsd";
public static final String LATEST_SCHEMA_LOCATION = DEFAULT_SCHEMA_LOCATION_VERSION_2_3;

// Top level...
public static final String NEUROML_ROOT = "neuroml";
Expand Down
23 changes: 23 additions & 0 deletions src/main/resources/bindings/NeuroML_v2.2.xjb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

<jxb:bindings version="2.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<jxb:bindings schemaLocation="../NeuroML_v2.2.xsd" node="/xs:schema">

<jxb:schemaBindings>
<jxb:package name="org.neuroml.model"/>
</jxb:schemaBindings>

<jxb:bindings node=".//xs:attribute[@name='morphology']">
<jxb:property name="morphologyAttr"/>
</jxb:bindings>

<jxb:bindings node=".//xs:attribute[@name='biophysicalProperties']">
<jxb:property name="biophysicalPropertiesAttr"/>
</jxb:bindings>


</jxb:bindings>

</jxb:bindings>
23 changes: 23 additions & 0 deletions src/main/resources/bindings/NeuroML_v2.3.xjb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

<jxb:bindings version="2.0"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<jxb:bindings schemaLocation="../NeuroML_v2.3.xsd" node="/xs:schema">

<jxb:schemaBindings>
<jxb:package name="org.neuroml.model"/>
</jxb:schemaBindings>

<jxb:bindings node=".//xs:attribute[@name='morphology']">
<jxb:property name="morphologyAttr"/>
</jxb:bindings>

<jxb:bindings node=".//xs:attribute[@name='biophysicalProperties']">
<jxb:property name="biophysicalPropertiesAttr"/>
</jxb:bindings>


</jxb:bindings>

</jxb:bindings>
22 changes: 17 additions & 5 deletions src/test/java/org/neuroml/model/test/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@
*/
public class AppTest extends TestCase {

public void testVersions() throws IOException {
System.out.println("Running a test on version usage, making all references to versions are: v" + NeuroMLElements.ORG_NEUROML_MODEL_VERSION + "...");

private boolean isInPom(String s) throws IOException{
File pom = new File("pom.xml");
String toFind = "<artifactId>org.neuroml.model</artifactId><version>"+NeuroMLElements.ORG_NEUROML_MODEL_VERSION+"</version>";
InputStream ins = new FileInputStream(pom);
InputStreamReader insr = new InputStreamReader(ins);
BufferedReader fr = new BufferedReader(insr);
Expand All @@ -32,7 +29,22 @@ public void testVersions() throws IOException {
fr.close();
String sdat = sb.toString();

assert(sdat.indexOf(toFind)>0);
return sdat.indexOf(s)>0;
}

public void testVersions() throws IOException {
System.out.println("Running a test on version usage, making all references to versions are: v" + NeuroMLElements.ORG_NEUROML_MODEL_VERSION + "...");


String toFind = "<artifactId>org.neuroml.model</artifactId><version>"+NeuroMLElements.ORG_NEUROML_MODEL_VERSION+"</version>";

assert(isInPom(toFind));

toFind = "<build.version2>"+NeuroMLElements.LATEST_SCHEMA_VERSION+"</build.version2>";

assert(isInPom(toFind));

assert(NeuroMLElements.LATEST_SCHEMA_LOCATION.indexOf(NeuroMLElements.LATEST_SCHEMA_VERSION)>0);

}

Expand Down

0 comments on commit fe071d7

Please sign in to comment.