-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from BuildingSync/develop
Release Version 1.0
- Loading branch information
Showing
213 changed files
with
203,372 additions
and
28,702 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,5 @@ | |
.git | ||
.tox | ||
docker/README.md | ||
static | ||
staticfiles | ||
node_modules | ||
bsyncviewer/collected_static | ||
bsyncviewer/media |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
language: python | ||
python: | ||
- '3.6.5' | ||
cache: pip | ||
addons: | ||
postgresql: '9.6' | ||
services: | ||
- postgresql | ||
env: | ||
global: | ||
- DJANGO_SETTINGS_MODULE=bsyncviewer.settings.travis | ||
matrix: | ||
- TOX_ENV=python | ||
- TOX_ENV=flake8 | ||
install: | ||
- sudo apt-get install python-enchant -y | ||
- pip install tox | ||
- pip install --upgrade pip | ||
- pip install tox coveralls | ||
before_script: | ||
- psql -c "CREATE DATABASE bsync_validator;" -U postgres | ||
script: | ||
- tox -e $TOX_ENV | ||
after_success: | ||
- test $TOX_ENV = "python" && coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# BuildingSync Use Case Selection Tool | ||
|
||
## Version 1.0 | ||
|
||
Date Range: Initial Commit - 11/15/19 | ||
|
||
- Official version 1.0 release of Use Case Selection Tool. | ||
- See README.md for more details | ||
|
||
Closed Issues and Features: | ||
- Fixed [#11]( https://github.com/BuildingSync/selection-tool/issues/11 ), Support Schematron | ||
- Fixed [#13]( https://github.com/BuildingSync/selection-tool/issues/13 ), Add BuildingSync Version 2.0-Prerelease |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,62 +2,66 @@ | |
# AUTHOR: Nicholas Long <[email protected]> | ||
# DESCRIPTION: Dockerfile for running BuildingSync Data Selection Tool | ||
# TO_BUILD_AND_RUN: docker-compose build && docker-compose up | ||
FROM alpine:3.8 | ||
|
||
# Latest Ubuntu LTS | ||
FROM ubuntu:16.04 | ||
|
||
### Required dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends npm \ | ||
nodejs \ | ||
build-essential \ | ||
git \ | ||
python2.7 \ | ||
python-pip \ | ||
python-dev \ | ||
python-gdbm \ | ||
libpq-dev \ | ||
libpcre3 \ | ||
libpcre3-dev \ | ||
enchant \ | ||
vim \ | ||
&& pip install --upgrade pip \ | ||
&& pip install setuptools \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& groupadd --gid 1000 uwsgi \ | ||
&& useradd -g uwsgi -M -u 1000 -r uwsgi \ | ||
&& ln -s /usr/bin/nodejs /usr/bin/node \ | ||
&& mkdir -p /srv/bs-tool | ||
|
||
### Note on some of the commands above | ||
### create the uwsgi user and groud | ||
### link the apt install of nodejs to node (expected by bower) | ||
### Install python requirements | ||
|
||
WORKDIR /srv/bs-tool | ||
COPY requirements.txt /srv/bs-tool/requirements.txt | ||
RUN apk add --no-cache python3 \ | ||
python3-dev \ | ||
postgresql-dev \ | ||
alpine-sdk \ | ||
pcre \ | ||
pcre-dev \ | ||
libxslt-dev \ | ||
linux-headers \ | ||
bash \ | ||
bash-completion \ | ||
ruby \ | ||
ruby-dev \ | ||
nginx && \ | ||
ln -sf /usr/bin/python3 /usr/bin/python && \ | ||
python -m ensurepip && \ | ||
rm -r /usr/lib/python*/ensurepip && \ | ||
ln -sf /usr/bin/pip3 /usr/bin/pip && \ | ||
pip install --upgrade pip setuptools && \ | ||
pip install git+https://github.com/Supervisor/supervisor@837c159ae51f3 && \ | ||
mkdir -p /var/log/supervisord/ && \ | ||
rm -r /root/.cache && \ | ||
addgroup -g 1000 uwsgi && \ | ||
adduser -G uwsgi -H -u 1000 -S uwsgi && \ | ||
mkdir -p /run/nginx && \ | ||
echo "daemon off;" >> /etc/nginx/nginx.conf && \ | ||
rm -f /etc/nginx/conf.d/default.conf && \ | ||
echo "gem: --no-rdoc --no-ri" > /etc/gemrc | ||
|
||
## Note on some of the commands above: | ||
## - create the uwsgi user and group to have id of 1000 | ||
## - copy over python3 as python | ||
## - pip install --upgrade pip overwrites the pip so it is no longer a symlink | ||
## - install supervisor that works with Python3. | ||
|
||
WORKDIR /srv/selection-tool | ||
COPY /requirements.txt /srv/selection-tool/requirements.txt | ||
RUN pip install -r requirements.txt | ||
|
||
### Install JavaScript requirements - do this first because they take awhile | ||
### and the dependencies will probably change slower than python packages. | ||
### README.md stops the no readme warning | ||
COPY bower.json /srv/bs-tool/bower.json | ||
COPY .bowerrc /srv/bs-tool/.bowerrc | ||
COPY package.json /srv/bs-tool/package.json | ||
COPY README.rst /srv/bs-tool/README.rst | ||
RUN npm update && npm install | ||
RUN $(npm bin)/bower install --config.interactive=false --allow-root | ||
#install the schematron-nokogiri gem | ||
RUN gem install schematron-nokogiri | ||
|
||
### Copy over the remaining part of the application and some helpers | ||
COPY . /srv/bs-tool/ | ||
COPY . /srv/selection-tool/ | ||
|
||
### Copy the wait-for-it command to /usr/local | ||
COPY /docker/wait-for-it.sh /usr/local/wait-for-it.sh | ||
|
||
RUN mkdir -p /srv/bs-tool/static && python manage.py collectstatic | ||
# nginx configurations - alpine doesn't use the sites-available directory. Put the selection tool | ||
# configuration file into the /etc/nginx/conf.d/ folder. | ||
COPY /docker/nginx.conf /etc/nginx/conf.d/selection_tool.conf | ||
# Supervisor looks in /etc/supervisor for the configuration file. | ||
COPY /docker/supervisord.conf /etc/supervisor/supervisord.conf | ||
|
||
# entrypoint sets some permissions on directories that may be shared volumes | ||
COPY /docker/bstool-entrypoint.sh /usr/local/bin/bstool-entrypoint | ||
RUN chmod 775 /usr/local/bin/bstool-entrypoint | ||
ENTRYPOINT ["bstool-entrypoint"] | ||
COPY /docker/selection-tool-entrypoint.sh /usr/local/bin/selection-tool-entrypoint | ||
RUN chmod 775 /usr/local/bin/selection-tool-entrypoint | ||
ENTRYPOINT ["selection-tool-entrypoint"] | ||
|
||
CMD ["supervisord"] | ||
|
||
EXPOSE 8000 | ||
EXPOSE 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
# BuildingSync Schema Viewer and Validator | ||
|
||
[![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. | ||
|
||
## Installation | ||
|
||
1. Clone the repository. | ||
1. Setup python 3. You can use a virtual environment: | ||
```bash | ||
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 | ||
psql -c 'DROP DATABASE bsync_validator;' | ||
psql -c 'CREATE DATABASE bsync_validator;' | ||
psql -c "CREATE USER bsync_validator WITH ENCRYPTED PASSWORD 'bsync_validator';" | ||
psql -c 'GRANT ALL PRIVILEGES ON DATABASE bsync_validator TO bsync_validator;' | ||
psql -c 'ALTER USER bsync_validator CREATEDB;' | ||
``` | ||
1. Install Django and associated requirements: | ||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
1. Initialize the database: | ||
```bash | ||
python manage.py migrate | ||
``` | ||
1. Create a superuser: | ||
```bash | ||
python manage.py createsuperuser | ||
``` | ||
1. Start the app: | ||
```bash | ||
python manage.py runserver | ||
``` | ||
|
||
|
||
## Local Development | ||
|
||
* When making changes to models, run the following command to make migrations: | ||
```bash | ||
python manage.py makemigrations | ||
python manage.py migrate | ||
``` | ||
|
||
* To test schema import, you can run this command: | ||
```bash | ||
python manage.py reset_schema --schema_version=1.0.0 | ||
``` | ||
|
||
|
||
### Testing | ||
|
||
* To run test: | ||
```bash | ||
./manage.py test | ||
``` | ||
|
||
* To calculate coverage: | ||
```bash | ||
coverage run --source='.' manage.py test | ||
coverage report | ||
``` | ||
|
||
### Pep | ||
|
||
* Run the following command to clean-up your code before committing: | ||
```bash | ||
autopep8 --in-place --aggressive --aggressive --recursive --max-line-length 100 --ignore E501,E402,W503,E731 --exclude=conf.py,structure.py . | ||
tox -e flake8 | ||
``` | ||
|
||
## Usage | ||
|
||
### BuildingSync Schema | ||
|
||
The BuildingSync Schema Viewer can support multiple versions of the BuildingSync schema. Admin users can manage schemas from the Django Administration console. Click on the 'Admin' link in the top navigation bar to access the Django Administration pages. | ||
|
||
To add a schema, specify the name, version, and schema file (XSD) to parse and save the record. The schema file will be parsed automatically. | ||
|
||
To modify an existing schema, click on the edit link. If changes are made to the uploaded XSD schema file and re-uploaded, ensure that the 'schema parsed' checkbox is unchecked before saving the record. This will trigger the automatic schema parsing. | ||
|
||
### Use Cases | ||
|
||
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'. | ||
|
||
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. | ||
|
||
Admin users: Find the use case in the Django Administration console and click the edit button. Check the 'Make public' checkbox and save. | ||
|
||
### Validator | ||
|
||
The validator page allows users to validate XMLs against the BuildingSync schema and its public use cases. It can be tried with selected example files, or custom XML files can be uploaded for validation. | ||
|
||
#### Validator API | ||
|
||
There is also a validator endpoint to validate XML files against the BuildingSync schema and its public use cases. | ||
|
||
Request: POST to https://selectiontool.buildingsync.net/api/validate | ||
Use form-data to specify the following parameters for schema version and XML file: ```schema_version``` and ```file```. | ||
|
||
Example Response: | ||
```json | ||
{ | ||
"schema_version": "1.0.0", | ||
"validation_results": { | ||
"schema": { | ||
"valid": true, | ||
"schema_version": "1.0.0" | ||
}, | ||
"use_cases": { | ||
"EXAMPLE USE CASE 1": { | ||
"valid": false, | ||
"errors": [ | ||
{ | ||
"path": "Audits.Audit.Sites.Site.Facilities.Facility.ConditionedFloorsAboveGrade", | ||
"message": "Required element not found" | ||
}, | ||
{ | ||
"path": "Audits.Audit.Sites.Site.Facilities.Facility.ConditionedFloorsBelowGrade", | ||
"message": "Required element not found" | ||
}, | ||
{ | ||
"path": "Audits.Audit.Sites.Site.Facilities.Facility.UnconditionedFloorsAboveGrade", | ||
"message": "Required element not found" | ||
} | ||
] | ||
}, | ||
"EXAMPLE USE CASE 2": { | ||
"valid": true | ||
} | ||
} | ||
}, | ||
"success": true | ||
} | ||
``` | ||
|
||
### BEDES | ||
|
||
BEDES parsing and mapping to the BuildingSync schema is not an automated process, due to the manual inspections/corrections required. | ||
|
||
To parse and map a new BEDES version: | ||
|
||
1. Download the ```bedes_online_dictionary_uuid-lo.xml``` and the ```bedes_online_dictionary_uuid-terms.xml``` files from the BEDES website. | ||
|
||
1. Place these new BEDES XMLs in the lib/bedes/vX.X directory. vX.X refers to the BEDES version here. | ||
|
||
1. Parse the BEDES XMLs into a JSON file and map the BEDES terms to the BuildingSync attributes: | ||
```bash | ||
python manage.py bedes --schema_version=X.X.X --bedes_version=X.X | ||
``` | ||
Note that the bedes_version contains a v, ex: v2.2. | ||
This will create a ```bedes_vX.X.json``` file in the lib/bedes/vX.X directory. It will also create 2 CSV files: ```bedes-mappings-enumerations.csv``` and ```bedes-mappings-terms.csv``` in the lib/bedes/vX.X/schemaX.X directory. | ||
|
||
*Note* — The BEDES terms must be mapped for each version of the BuildingSync schema by calling the ```python manage.py bedes``` command above. | ||
|
||
1. Review these mapping files and make changes as needed. | ||
|
||
1. Once satisfied with the mappings, run the same command with the --save_to_db flag: | ||
```bash | ||
python manage.py bedes --schema_version=X.X.X --bedes_version=X.X --save_to_db | ||
``` | ||
Note that you must run this command without the --save_to_db flag first, in order to create the CSV files. | ||
|
Oops, something went wrong.