Skip to content

Commit

Permalink
Merge pull request #48 from BuildingSync/develop
Browse files Browse the repository at this point in the history
Version 1.1.1
  • Loading branch information
nllong authored Mar 27, 2020
2 parents e4e15e8 + 4b74c32 commit d245e5a
Show file tree
Hide file tree
Showing 71 changed files with 1,331 additions and 267 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,3 @@ bsyncviewer/lib/bedes/v2.2/schema0.0.1/
bsyncviewer/lib/bedes/*/schema*/bedes-mappings-enumerations.csv
bsyncviewer/lib/bedes/*/schema*/bedes-mappings-terms.csv
bsyncviewer/lib/bedes/*/schema*/bsync_unique_words.csv

23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: check-merge-conflict
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
# - id: requirements-txt-fixer
- id: mixed-line-ending
- id: flake8
args: ['--max-line-length=140'] # default of Black

- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.4
hooks:
- id: isort
args: ['-m 3'] # vertical hanging
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# BuildingSync Use Case Selection Tool

## Version 1.1.1

General updates:

* Parser changes to handle restriction by pattern
* Adding L000 OpenStudio Simulation use case and example files
* Dockerize TestSuite repository

Date Range: 12/21/20 - 03/26/20


## Version 1.1.0

Date Range: 11/19/19 - 12/20/19
Expand Down
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN apk add --no-cache python3 \
linux-headers \
bash \
bash-completion \
git \
ruby \
ruby-dev \
nginx && \
Expand Down Expand Up @@ -42,9 +43,15 @@ WORKDIR /srv/selection-tool
COPY /requirements.txt /srv/selection-tool/requirements.txt
RUN pip install -r requirements.txt

#install the schematron-nokogiri gem
RUN gem install schematron-nokogiri
#install the schematron-nokogiri gem from BuildingSync org
WORKDIR /srv
RUN git clone https://github.com/BuildingSync/schematron
WORKDIR /srv/schematron

RUN gem build schematron-nokogiri.gemspec
RUN gem install schematron-nokogiri-0.0.3.gem

WORKDIR /srv/selection-tool
### Copy over the remaining part of the application and some helpers
COPY . /srv/selection-tool/

Expand Down
60 changes: 53 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

[![Build Status](https://travis-ci.org/BuildingSync/selection-tool.svg?branch=develop)](https://travis-ci.org/BuildingSync/selection-tool)

This is the repository for the BuildingSync Validator web application.
This is the repository for the BuildingSync Validator web application.

## Installation

1. Clone the repository.
1. Setup python 3. You can use a virtual environment:
```bash
pyenv install 3.6.5
pyenv install 3.6.5
pyenv virtualenv 3.6.5 bsync-validator-3.6.5
pyenv local bsync-validator-3.6.3
```
```
1. Install PostgreSQL server for local development (if desired)
* Once installed, create your local database and user:
```bash
Expand All @@ -26,6 +26,15 @@ This is the repository for the BuildingSync Validator web application.
```bash
pip install -r requirements.txt
```
1. Install the schematron-nokogiri gem for schematron use case validation. We are using a forked version to handle OpenStudio Simulation use cases which contain abstract patterns.
```bash
git clone https://github.com/BuildingSync/schematron.git
cd schematron
gem build schematron-nokogiri.gemspec
gem install schematron-nokogiri-0.0.3.gem
```

1. Initialize the database:
```bash
python manage.py migrate
Expand Down Expand Up @@ -53,6 +62,20 @@ This is the repository for the BuildingSync Validator web application.
python manage.py reset_schema --schema_version=1.0.0
```

### Precommit

This project used `pre-commit <https://pre-commit.com/>`_ to ensure code consistency. To enable pre-commit, run the following from the command line.

```bash
pip install pre-commit
pre-commit install
```

To run pre-commit against the files without calling git commit, then run the following. This is useful when cleaning up the repo before committing.

```bash
pre-commit run --all-files
```

### Testing

Expand Down Expand Up @@ -91,7 +114,7 @@ To modify an existing schema, click on the edit link. If changes are made to th
Authenticated users can add private use cases to the BuildingSync Schema Viewer. Use cases are represented by a schematron file that defines a set of rules and patterns.

To add a use case, click on the 'Use Case' link in the top navigation bar, then click on the '+ New Use Case' button.
Select a name and a BuildingSync schema version. Select your use case definitions schematron file and upload, then click 'Submit'.
Select a name and a BuildingSync schema version. Select your use case definitions schematron file and upload, then click 'Submit'.

Once ready, contact a BuildingSync admin to make the use case public. Public use cases will be available on the 'Validator' page to validate XML files submitted by users.

Expand Down Expand Up @@ -178,16 +201,39 @@ Follow these steps to add a new schema version to the selection tool:
1. Add the schema file in the admin interface. Must have admin privileges. The schema will get automatically parsed.
1. Convert existing use cases schematron files to the new schema. Add the new use cases.
1. When the use cases have been reviewed, make them public in the admin interface.
1. Create XML example files and place them in the `lib/validator/examples/schema<VERSION>` directory.
1. Create XML example files and place them in the `lib/validator/examples/schema<VERSION>` directory.
1. Test the validator with the new XML example files.
1. Reparse bedes terms to map them to the new schema following the steps in the BEDES section above.

### Adding Examples from the TestSuite
### Adding Examples from the TestSuite repo

Follow these steps to add new example tables from the TestSuite
Follow these steps to add new example tables from the TestSuite repo

1. Clone the [TestSuite](https://github.com/BuildingSync/TestSuite) repo
2. Install [pandoc](https://pandoc.org/installing.html)
3. Convert the TestSuite README to html:
``` pandoc README.md -s -o README.html ```
4. Copy the tables part of the README.html and paste to replace the old content in ```bsyncviewer/templates/examples.html```.

### Adding an OpenStudio Simulation Use Case from the TestSuite repo

1. The relevant files are currently on the L000_Schematron branch of the [TestSuite](https://github.com/BuildingSync/TestSuite/tree/L100_Schematron) repo. Clone the repo locally.
1. OpenStudio Simulation use case schematron files include patterns from a [library of schematron files](https://github.com/BuildingSync/TestSuite/tree/L100_Schematron/lib). Copy these files from the TestSuite repo into the selection-tool at the following location: ```bsyncviewer/testsuitelib```.
1. Open the relevant use case file from the TestSuite repo. For example: [L00_OpenStudio_Simulation.sch](https://github.com/BuildingSync/TestSuite/blob/L100_Schematron/spec/use_cases/schema2.0.0/L000_OpenStudio_Simulation.sch). Edit the include statements at the top of the file with relative paths to the selection-tool testsuitelib directory. Save the file.
```bash
<include href="../../testsuitelib/rootElements.sch#root.oneOfEachUntilBuilding"/>
<include href="../../testsuitelib/rootElements.sch#root.oneOfEachFacilityUntilScenario"/>
<include href="../../testsuitelib/siteBuildingElements.sch#sbe.cityStateOrClimateZone"/>
<include href="../../testsuitelib/scenarioElements.sch#sc.baseline.ID"/>
<include href="../../testsuitelib/scenarioElements.sch#sc.baseline.asPackageOfMeasures"/>
<include href="../../testsuitelib/buildingElements.sch#be.L000BuildingInfo"/>
<include href="../../testsuitelib/floorElements.sch#fa.oneOfType"/>
<include href="../../testsuitelib/floorElements.sch#fa.haveTypeAndValue"/>
```
1. Add the use case to the selection-tool by browsing to the ```/use_cases``` URL and clicking the *New Use Case* button.
1. Fill out the name, description, and schema version
1. Upload the file that was modified in the previous step
1. Save
1. Make the use case public from the selection-tool admin interface.
1. If you have any example files to add to the selection-tool (for example, for the L000 OpenStudio Simulation use case, there are [2 examples files](https://github.com/BuildingSync/TestSuite/tree/L100_Schematron/spec/use_cases/schema2.0.0/examples)), add them in the appropriate schema directory in ```bsyncviewer/lib/validator/examples```. Regenerate the ```example_files.zip``` archive. This will make the files available as examples at the ```/validator``` URL.
1. You can now validate XMLs against the new use case.
2 changes: 1 addition & 1 deletion app_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.1.1
2 changes: 1 addition & 1 deletion bsyncviewer/admin.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import semantic_version
from django import forms
from django.contrib import admin
from django.contrib.admin import AdminSite
from django.contrib.auth.admin import GroupAdmin, UserAdmin
from django.contrib.auth.models import Group, User
from django import forms

from .models.attribute import Attribute
from .models.schema import Schema
Expand Down
1 change: 1 addition & 0 deletions bsyncviewer/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.conf import settings

from .models.schema import Schema

DEFAULT_SCHEMA_VERSION = settings.DEFAULT_SCHEMA_VERSION


Expand Down
3 changes: 1 addition & 2 deletions bsyncviewer/lib/bedes/bedes_parser.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import json
import os
from collections import defaultdict, OrderedDict, Mapping
from collections import Mapping, OrderedDict, defaultdict

import xmltodict


# BEDES have a very simple two level hierarchy. The first level is the category and the
# second category is the Term. The data are stored in this format, but it is important
# to note that the Term is globally unique.
Expand Down
12 changes: 6 additions & 6 deletions bsyncviewer/lib/bedes/v2.2/bedes_online_dictionary_uuid-lo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36246,8 +36246,8 @@ environment.</List-Option-Definition>
<Content-UUID>b6fca2b4-5856-452a-9198-1a0455dd73f0</Content-UUID>
<URL>https://bedes.lbl.gov/node/b6fca2b4-5856-452a-9198-1a0455dd73f0</URL>
<List-Option>WELL Educational Facilities (Pilot)</List-Option>
<List-Option-Definition>Educational Facilities applies to projects where dedicated staff are employed for instructional purposes, and students may be of any age.
Courses may cover any range of topics, and facilities may be typified by fully scheduled days, or distinct classes that students enroll in at will.
<List-Option-Definition>Educational Facilities applies to projects where dedicated staff are employed for instructional purposes, and students may be of any age.
Courses may cover any range of topics, and facilities may be typified by fully scheduled days, or distinct classes that students enroll in at will.
The education pilot standard is applicable to early education, K-12, and adult education (college, university, or other).</List-Option-Definition>
<Unit-of-Measure>N/A</Unit-of-Measure>
<Related-Term>Assessment Recognition</Related-Term>
Expand All @@ -36260,8 +36260,8 @@ The education pilot standard is applicable to early education, K-12, and adult e
<Content-UUID>51c3b1c9-2ffd-4b1a-84b8-bd86d675a4dc</Content-UUID>
<URL>https://bedes.lbl.gov/node/51c3b1c9-2ffd-4b1a-84b8-bd86d675a4dc</URL>
<List-Option>WELL Multifamily Residential (Pilot)</List-Option>
<List-Option-Definition>Multifamily Residential applies specifically to projects with at least five dwelling units in a single building with common structural elements.
Projects that qualify include apartments, condominiums, townhouses, and other residential complexes within all market thresholds -
<List-Option-Definition>Multifamily Residential applies specifically to projects with at least five dwelling units in a single building with common structural elements.
Projects that qualify include apartments, condominiums, townhouses, and other residential complexes within all market thresholds -
affordable housing, market-rate, and luxury.</List-Option-Definition>
<Unit-of-Measure>N/A</Unit-of-Measure>
<Related-Term>Assessment Recognition</Related-Term>
Expand Down Expand Up @@ -36322,8 +36322,8 @@ affordable housing, market-rate, and luxury.</List-Option-Definition>
<Content-UUID>a3b99610-6784-432f-b07e-65385daf0f16</Content-UUID>
<URL>https://bedes.lbl.gov/node/a3b99610-6784-432f-b07e-65385daf0f16</URL>
<List-Option>WELL Retail (Pilot)</List-Option>
<List-Option-Definition>Retail applies to locations where consumers can view and purchase merchandise onsite, and staff are employed to assist in the sale of
products. The Retail pilot standard is applicable to both owner- and tenant-occupied projects, and to both those in stand-alone retail
<List-Option-Definition>Retail applies to locations where consumers can view and purchase merchandise onsite, and staff are employed to assist in the sale of
products. The Retail pilot standard is applicable to both owner- and tenant-occupied projects, and to both those in stand-alone retail
buildings and/ or those integrated into larger structures.</List-Option-Definition>
<Unit-of-Measure>N/A</Unit-of-Measure>
<Related-Term>Assessment Recognition</Related-Term>
Expand Down
2 changes: 1 addition & 1 deletion bsyncviewer/lib/bedes/v2.2/bedes_v2.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -46155,4 +46155,4 @@
"list_options": []
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15888,4 +15888,4 @@ Window spacing: the dimension between windows in a discrete window layout. (in.)
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
</xs:schema>
8 changes: 6 additions & 2 deletions bsyncviewer/lib/schema_parser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import xmlschema

from bsyncviewer.models.attribute import Attribute
from bsyncviewer.models.attribute_enumeration_class import (
AttributeEnumerationClass
)
from bsyncviewer.models.enumeration import Enumeration, EnumerationClass
from bsyncviewer.models.attribute_enumeration_class import AttributeEnumerationClass
from django.db import transaction


Expand Down Expand Up @@ -107,6 +108,7 @@ def __init__(self):
self.enumerations = []
self.min_inclusive = 0
self.max_inclusive = 0
self.pattern = ''


class ChoiceElement(BuildingSyncSchemaElement):
Expand Down Expand Up @@ -314,6 +316,8 @@ def _read_restriction(parent_object):
this_restriction.min_inclusive = child.attrib['value']
elif child.tag.endswith('maxInclusive'):
this_restriction.max_inclusive = child.attrib['value']
elif child.tag.endswith('pattern'):
this_restriction.pattern = child.attrib['value']
else:
raise Exception("Invalid tag type in _read_restriction: " + child.tag)
return this_restriction
Expand Down
2 changes: 1 addition & 1 deletion bsyncviewer/lib/use_cases/bricr_use_case_ashrae_v1.0.0.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3521,4 +3521,4 @@ BuildingSync.Facilities.Facility.Tenants.Tenant.UserDefinedFields.UserDefinedFie
BuildingSync.Facilities.Facility.UserDefinedFields,,,,,
BuildingSync.Facilities.Facility.UserDefinedFields.UserDefinedField,,,,,
BuildingSync.Facilities.Facility.UserDefinedFields.UserDefinedField.FieldName,,,,,
BuildingSync.Facilities.Facility.UserDefinedFields.UserDefinedField.FieldValue,,,,,
BuildingSync.Facilities.Facility.UserDefinedFields.UserDefinedField.FieldValue,,,,,
2 changes: 1 addition & 1 deletion bsyncviewer/lib/use_cases/bricr_use_case_v1.0.0.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3521,4 +3521,4 @@ BuildingSync.Facilities.Facility.Tenants.Tenant.UserDefinedFields.UserDefinedFie
BuildingSync.Facilities.Facility.UserDefinedFields,,,,,
BuildingSync.Facilities.Facility.UserDefinedFields.UserDefinedField,,,,,
BuildingSync.Facilities.Facility.UserDefinedFields.UserDefinedField.FieldName,,,,,
BuildingSync.Facilities.Facility.UserDefinedFields.UserDefinedField.FieldValue,,,,,
BuildingSync.Facilities.Facility.UserDefinedFields.UserDefinedField.FieldValue,,,,,
2 changes: 1 addition & 1 deletion bsyncviewer/lib/use_cases/ll87_usecase_schematron.sch
Original file line number Diff line number Diff line change
Expand Up @@ -6970,4 +6970,4 @@
<sch:assert test="(number(text()) = text()) and (number() &gt;= 0)">text "<sch:value-of select="text()"/>": element "text()" MUST be a number and MUST be greater than or equal to 0</sch:assert>
</sch:rule>
</sch:pattern>
</sch:schema>
</sch:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -1623,4 +1623,4 @@
</auc:Report>
</auc:Facility>
</auc:Facilities>
</auc:BuildingSync>
</auc:BuildingSync>
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@
<auc:ContactEmailAddress>[email protected]</auc:ContactEmailAddress>
</auc:ContactEmailAddresses>
</auc:Contact>
</auc:Contacts>
</auc:Contacts>
<auc:UserDefinedFields>
<auc:UserDefinedField>
<auc:FieldName>BIN</auc:FieldName>
Expand Down Expand Up @@ -802,4 +802,4 @@
<auc:FieldValue>1234</auc:FieldValue>
</auc:UserDefinedField>
</auc:UserDefinedFields>
</auc:BuildingSync>
</auc:BuildingSync>
Original file line number Diff line number Diff line change
Expand Up @@ -948,4 +948,4 @@
</auc:UserDefinedField>
</auc:UserDefinedFields>
</auc:Audit>
</auc:Audits>
</auc:Audits>
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
</auc:Scenario>
</auc:Scenarios>
</auc:Report>
</auc:Reports>
</auc:Reports>
</auc:Facility>
</auc:Facilities>
</auc:BuildingSync>
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@
<auc:ContactEmailAddress>[email protected]</auc:ContactEmailAddress>
</auc:ContactEmailAddresses>
</auc:Contact>
</auc:Contacts>
</auc:Contacts>
<auc:UserDefinedFields>
<auc:UserDefinedField>
<auc:FieldName>BIN</auc:FieldName>
Expand Down Expand Up @@ -802,4 +802,4 @@
<auc:FieldValue>1234</auc:FieldValue>
</auc:UserDefinedField>
</auc:UserDefinedFields>
</auc:BuildingSync>
</auc:BuildingSync>
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
</auc:Scenario>
</auc:Scenarios>
</auc:Report>
</auc:Reports>
</auc:Reports>
</auc:Facility>
</auc:Facilities>
</auc:BuildingSync>
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@
<auc:ContactEmailAddress>[email protected]</auc:ContactEmailAddress>
</auc:ContactEmailAddresses>
</auc:Contact>
</auc:Contacts>
</auc:Contacts>
<auc:UserDefinedFields>
<auc:UserDefinedField>
<auc:FieldName>BIN</auc:FieldName>
Expand Down Expand Up @@ -802,4 +802,4 @@
<auc:FieldValue>1234</auc:FieldValue>
</auc:UserDefinedField>
</auc:UserDefinedFields>
</auc:BuildingSync>
</auc:BuildingSync>
Loading

0 comments on commit d245e5a

Please sign in to comment.