Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/buildingmotif-app/lo…
Browse files Browse the repository at this point in the history
…ader-utils-2.0.4
  • Loading branch information
haneslinger authored Dec 15, 2022
2 parents 4a424b2 + 1045e33 commit d535aa0
Show file tree
Hide file tree
Showing 126 changed files with 12,562 additions and 2,735 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: build-deploy-docs

on:
push:
branches:
- main
# If your git repository has the Jupyter Book within some-subfolder next to
# unrelated files, you can make this run only if a file within that specific
# folder has been modified.
#
# paths:
# - some-subfolder/**

# This job installs dependencies, builds the book, and pushes it to `gh-pages`
jobs:
build-deploy-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: 3.10.4

- name: install dependencies
run: |
pip install poetry
poetry install
- name: install project
run: pip install .

- name: install jupyter book
run: pip install -U jupyter-book

- name: build jupyter book
working-directory: ${{runner.workspace}}/BuildingMOTIF/docs/
run: jupyter-book build .

# TODO can we use an official GitHub Action? https://github.com/actions/deploy-pages
- name: GitHub Pages action
uses: peaceiris/actions-gh-pages@v3.6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html
4 changes: 2 additions & 2 deletions .github/workflows/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
runs-on: ubuntu-latest
name: Assign to Project
steps:
- name: Assign New issues and New pull requests to project FY22
- name: Assign New issues and New pull requests to project FY23
uses: srggrs/assign-one-project-github-action@1.3.1
if: github.event.action == 'opened'
with:
project: 'https://github.com/NREL/BuildingMOTIF/projects/1'
project: 'https://github.com/NREL/BuildingMOTIF/projects/2'
12 changes: 7 additions & 5 deletions .github/workflows/repo-vis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ jobs:
repo-vis:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Update diagram
- name: checkout code
uses: actions/checkout@main

- name: update repo diagram
uses: githubocto/repo-visualizer@main
with:
excluded_paths: "ignore,.github"
commit_message: "Repo visualizer: updated diagram [skip ci]"
output_file: docs/reference/apidoc/diagram.svg
excluded_paths: ".github"
commit_message: "update repo diagram [skip ci]"
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ coverage.xml



# Sphinx documentation
docs/build/
# Jupyter Book documentation
docs/_build/
docs/reference/apidoc/_autosummary


# Jupyter Notebook
Expand Down
31 changes: 0 additions & 31 deletions .readthedocs.yaml

This file was deleted.

36 changes: 36 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
BSD 3-Clause License

Copyright (c) 2022, Alliance for Sustainable Energy, LLC.
All rights reserved.

NOTICE: This Software was developed under funding from the U.S. Department of
Energy and the U.S. Government consequently retains certain rights. As such,
the U.S. Government has been granted for itself and others acting on its
behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software
to reproduce, distribute copies to the public, prepare derivative works, and
perform publicly and display publicly, and to permit others to do so.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
124 changes: 39 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,41 @@
# BuildingMOTIF
[![Documentation Status](https://readthedocs.org/projects/buildingmotif/badge/?version=latest)](https://buildingmotif.readthedocs.io/en/latest/?badge=latest)
# BuildingMOTIF

[![codecov](https://codecov.io/gh/NREL/BuildingMOTIF/branch/main/graph/badge.svg?token=HAFSYH45NX)](https://codecov.io/gh/NREL/BuildingMOTIF)
[![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://nrel.github.io/BuildingMOTIF/)

> *Enabling the enabling technology of semantic interoperability.*
Semantic Interoperability in buildings through standardized semantic metadata is crucial to unlocking the value of the abundant and diverse networked data in buildings, avoiding subsequent data incompatibility/interoperability issues, and paving the way for advanced building technologies like Automated Fault Detection and Diagnostics (AFDD), real-time energy optimization, other energy management information systems ([EMIS](https://www.energy.gov/eere/femp/what-are-energy-management-information-systems)), improved HVAC controls, and grid-interactive energy efficient building ([GEB](https://www.energy.gov/eere/buildings/grid-interactive-efficient-buildings)) technologies, all of which are needed to fully de-carbonize buildings. Utilizing the capabilities of [Semantic Web](https://www.w3.org/standards/semanticweb/), it is possible to standardize building metadata in structured, expressive, and machine-readable ways, but at the same time it is very important to make it easier to implement for field practitioners without advanced knowledge in computer science.

***Building Metadata OnTology Interoperability Framework (BuildingMOTIF)*** bridges that gap between theory and practice, by offering a toolset for building metadata creation, storage, visualization, and validation. It is offered in the form of an SDK with easy-to-use APIs that abstract the underlying complexities of [RDF](https://www.w3.org/RDF/) graphs, database management, [SHACL](https://www.w3.org/TR/shacl/) validation, and interoperability between different metadata schemas/ontologies. It also supports connectors for easier integration with existing metadata sources (e.g., Building Automation System data, design models, existing metadata models, etc.), which are available at different phases of the building life-cycle.

The objectives of the ***BuildingMOTIF*** toolset are the following:
1. lower costs, reduce installation time, and improve delivered quality of building controls and services for building owners and occupants
2. enable a simpler and more easily verifiable procurement process for products and services for building managers
3. open new business opportunities for service providers, by removing knowledge barriers for parties implementing building controls and services

Currently, ***BuildingMOTIF*** is planned to support the [Brick Schema](https://brickschema.org/), [Project Haystack](https://project-haystack.org/), and the proposed [ASHRAE Standard 223P](https://www.ashrae.org/about/news/2018/ashrae-s-bacnet-committee-project-haystack-and-brick-schema-collaborating-to-provide-unified-data-semantic-modeling-solution), and to offer both a UI and underlying SDK with tutorials and reference documentation to be useful for different levels of expertise of users for maximum adoption.

# Documentation

The documentation uses [Diataxis](https://diataxis.fr/) as a framework for its structure, which is organized into the following sections.

## Tutorials

- [Model Creation](https://nrel.github.io/BuildingMOTIF/tutorials/model_creation.html)
- [Model Validation](https://nrel.github.io/BuildingMOTIF/tutorials/model_validation.html)
- [Model Correction](https://nrel.github.io/BuildingMOTIF/tutorials/model_correction.html)
- [Template Writing](https://nrel.github.io/BuildingMOTIF/tutorials/template_writing.html)

## How-to Guides

🏗️ under construction

## Reference

- [Code Documentation](https://nrel.github.io/BuildingMOTIF/reference/apidoc/index.html)
- [Developer Documentation](https://nrel.github.io/BuildingMOTIF/reference/developer_documentation.html)

## Explanation

The Building Metadata OnTology Interoperability Framework (BuildingMOTIF) is a tool for working with the following semantic data models.

- [ASHRAE 223P](https://www.ashrae.org/about/news/2018/ashrae-s-bacnet-committee-project-haystack-and-brick-schema-collaborating-to-provide-unified-data-semantic-modeling-solution)
- [Brick](https://brickschema.org/)
- [Project Haystack](https://project-haystack.org/)

# Installing
Install [Python >= 3.8.0](https://www.python.org/downloads/).
```
pip install buildingmotif
```

# Using
See the `notebooks` directory.

# Developing
1. Install [Python >= 3.8.0](https://www.python.org/downloads/).
2. Install [Poetry](https://python-poetry.org/docs/#installation).
3. Clone, download, or fork this repository.
4. Install dependenices with poetry.
```
poetry install
poetry run pre-commit install
```
5. To initialize your database, create your local configs file, enter your db uri, and run the migrations.
```
cp configs.py.dist configs.py
echo "DB_URI = 'sqlite:////path/to/db.db'" > configs.py
poetry run alembic upgrade head
```
## Uping the API
```
poetry run python buildingmotif/api/app.py
```
API will run on localhost:5000
## Testing
```
poetry run pytest
```
To run tests with DEBUG prints add the `-o log_cli=true` argument to the command
## Formatting
```
poetry run black .
poetry run isort .
poetry run pylama
```
## Migrating
After making changes to the tables, you must make a new db migration.
```
poetry run alembic revision -m "Description of Changes." --autogenerate
```
Additional changes may need to be made to the migration, so be sure to check it. [Read here](https://alembic.sqlalchemy.org/en/latest/autogenerate.html#auto-generating-migrations) for more information on alembic autogenerate migrations.
## Documenting
Documentation can be built locally with the following command, which will make the HTML files in the `docs/build/html/` directory.
```
cd docs
poetry run make html
```
## Building and Publishing
```
# build and publish test
poetry publish --build --dry-run

# build and publish
poetry publish --build
```
## Web App
1. [Download Node.js](https://nodejs.org/en/download/)
2. [Install Angular](https://angular.io/guide/setup-local)
3. See [buildingmotif-app/README.md](buildingmotif-app/README.md)
# Visualizing
![repo-vis](./diagram.svg)
🏗️ under construction
5 changes: 5 additions & 0 deletions buildingmotif-app/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import { ModelSearchComponent } from '../app/model-search/model-search.component
import { ModelSearchResolver } from '../app/model-search/model-search.resolver'
import { ModelDetailComponent } from '../app/model-detail/model-detail.component'
import { ModelDetailResolver } from '../app/model-detail/model-detail.resolver'
import { TemplateEvaluateComponent} from './template-evaluate/template-evaluate.component'
import { TemplateEvaluateResolver} from './template-evaluate/template-evaluate.resolver'
import { ModelNewComponent } from '../app/model-new/model-new.component'

const routes: Routes = [
{ path: 'models/new', component: ModelNewComponent},
{ path: 'templates/:id', component: TemplateDetailComponent },
{ path: 'templates/:id/evaluate', component: TemplateEvaluateComponent, resolve: {TemplateEvaluateResolver}},
{ path: 'models/:id', component: ModelDetailComponent, resolve: {ModelDetailResolver} },
{ path: 'templates', component: TemplateSearchComponent, resolve: {templateSearch:TemplateSearchResolver}},
{ path: 'models', component: ModelSearchComponent, resolve: {ModelSearchResolver}},
Expand Down
17 changes: 14 additions & 3 deletions buildingmotif-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ import {MatButtonModule} from '@angular/material/button';
import { ModelDetailComponent } from './model-detail/model-detail.component';
import {MatSnackBarModule} from '@angular/material/snack-bar';
import { CodemirrorModule } from '@ctrl/ngx-codemirror';
import {MatCardModule} from '@angular/material/card';
import {MatCardModule} from '@angular/material/card';
import { TemplateEvaluateFormComponent } from './template-evaluate/template-evaluate-form/template-evaluate-form.component';
import { TemplateDetailService } from './template-detail/template-detail.service';
import {MatTableModule} from '@angular/material/table';
import { TemplateEvaluateResultComponent } from './template-evaluate/template-evaluate-result/template-evaluate-result.component';
import { TemplateEvaluateComponent} from './template-evaluate/template-evaluate.component'
import { ModelNewComponent } from './model-new/model-new.component';

@NgModule({
declarations: [
Expand All @@ -35,6 +41,10 @@ import {MatCardModule} from '@angular/material/card';
ModelSearchComponent,
MenuComponent,
ModelDetailComponent,
TemplateEvaluateComponent,
TemplateEvaluateFormComponent,
TemplateEvaluateResultComponent,
ModelNewComponent,
],
imports: [
BrowserModule,
Expand All @@ -55,9 +65,10 @@ import {MatCardModule} from '@angular/material/card';
MatButtonModule,
MatSnackBarModule,
CodemirrorModule,
MatCardModule
MatCardModule,
MatTableModule
],
providers: [],
providers: [TemplateDetailService],
bootstrap: [AppComponent]
})
export class AppModule { }
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export class ModelDetailService {
);
}

updateModelGraph(id: number, newGraph: string) {
updateModelGraph(id: number, newGraph: string, append: boolean = false) {
const headers = {'Content-Type': "application/xml"}

return this.http.patch(`http://localhost:5000/models/${id}/graph`, newGraph, {headers, responseType: 'text'})
return this.http[append? "patch": "put"](`http://localhost:5000/models/${id}/graph`, newGraph, {headers, responseType: 'text'})
.pipe(
retry(3), // retry a failed request up to 3 times
catchError(this.handleError) // then handle the error
Expand Down
10 changes: 10 additions & 0 deletions buildingmotif-app/src/app/model-new/model-new.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.container {
padding: 3rem;
}

.new-model-form{
padding: 3rem;
width: 30rem;
display: flex;
flex-direction: column;
}
24 changes: 24 additions & 0 deletions buildingmotif-app/src/app/model-new/model-new.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="container">
<div> New Model </div>
<form class="new-model-form" [formGroup]="newModelForm">
<mat-form-field appearance="outline" floatLabel="never">
<input type="text"
aria-label="model name"
placeholder="model name"
matInput
formControlName="nameControl">
<mat-error *ngIf="newModelForm.get('nameControl')?.hasError('invalidCharacter')">
cannot contain &lt;, >, ", ^, &#123;, }, &vert;, \, ^, or spaces
</mat-error>
</mat-form-field>
<mat-form-field appearance="outline" floatLabel="never">
<textarea type="text"
aria-label="model description"
placeholder="model description"
matInput
formControlName="descriptionControl">
</textarea>
</mat-form-field>
</form>
<button mat-raised-button color="primary" (click)="createModel()" [disabled]="newModelForm.invalid"> New Model </button>
</div>
Loading

0 comments on commit d535aa0

Please sign in to comment.