Giter VIP home page Giter VIP logo

tasty's Introduction

tasty Documentation Status

Tasty was created to simplify the generation and validation of metadata related to buildings and intends to support the following schemas.

Installing

Prerequisites

  • Clone or download the repository.
  • Install Python (>=3.3 recommended).
  • Install Poetry.

Steps

  1. Create a virtual environment within the repository. The following command will create a virtual environment with venv (included with Python >=3.3) named venv_name.
    python3 -m venv venv_name
  2. Install dependencies.
    poetry install
  3. Run tasty to confirm that it's working, which should show a message describing its usage.
    poetry run tasty

Using

Generate shapes

The core shape templates (tasty/source_shapes/*) are used to generate the SHACL shape files. Run the following to generate the SHACL shape files locally.

poetry run tasty generate-shapes

OAP shapes

Tasty can scrape the BuildingsIOT Ontology Alignment Project (OAP) for all of their points and functions and then use these to create a source shapes file with the following commands.

  1. Scrape data to tasty/utils/temp/.
    poetry run python tasty/utils/scrape_oap.py
  2. Generate shapes to tasty/source_shapes/haystack/oap.json.
    poetry run python tasty/utils/generate_oap.py

Run tests

You should now be able to run the tests, make sure they are all passing:

poetry run pytest

Generate input file to use for validation

You can use tasty to help you validate instance data against specific shapes. To do this, you must first generate an input file. Each row in an input file corresponds to an entity in your instance data. An input file will contain the following column headers:

  • entity-id: A namespaced id for entities in a data file you would like to validate.
  • entity-name: Optionally a description for the entity, helpful for reading.

Additional column headers will exist for each of the shapes you want to use to validate your data. The easiest way to generate an input file is to also merge in data from an existing RDF graph (-dg option). Try this with one of the test files (an input-file.csv will appear in your root directory):

poetry run tasty generate-input -dg tests/files/data/haystack_g36_data_3_9_10.ttl
  • Add the -c flag to only add composite shapes to your input file. Composite meaning shapes having other shape, i.e. a shape for a specific vav box configuration, etc.

Validate instance data

Using the generated input-file.csv, mark an X in the cells according to the shape you want the entity to validate against. Using the example generated from above, the following should be true:

Entity phShapes:G36-Base-VAV-Shape phShapes:G36-CoolingOnly-VAV-Shape phShapes:G36-HotWaterReheat-VAV-Shape phShapes:HotWaterReheatFdbk-VAV-Shape
VAV-01 Valid Valid Invalid Invalid
VAV-02 Valid Valid Valid Valid
VAV-03 Valid Valid Valid Valid

Save the file. Each entity can now be validated against the indicated shape. To validate the file, simply run:

poetry run tasty validate -dg tests/files/data/haystack_g36_data_3_9_10.ttl

Outputs will be printed to the terminal, but you can also find a validation report as a ttl file in your root. Should look something like results-haystack_g36_data_3_9_10.ttl.

Python

There are also some simple classes that can take advantage of the types built-in to Brick / Haystack.

from rdflib import Namespace
import tasty.constants as tc
import tasty.graphs as tg
from tasty.entities import HaystackPointDefs, HaystackEquipDefs, BrickPointDefs, BrickEquipmentDefs

# Create a namespace and load in a blank Brick / Haystack graph
EX = Namespace('example.com#')
hg = tg.get_versioned_graph(tc.HAYSTACK, tc.V3_9_10)
bg = tg.get_versioned_graph(tc.BRICK, tc.V1_1)

# Specify the schema version (tc.V9_9_10, etc.) to use
hp = HaystackPointDefs(tc.V3_9_10)
bp = BrickPointDefs(tc.V1_1)
he = HaystackEquipDefs(tc.V3_9_10)
be = BrickEquipmentDefs(tc.V1_1)

# Bind all of the first class types as attributes
hp.bind()
bp.bind()
he.bind()
be.bind()

# Create a new point from one of the types and view the docs
chw_flow_sensor = hp.chilled_water_flow_sensor.deep_copy()
chw_flow_sensor.type_docs() # 'Sensor which measures the volumetric flow of chilled water'
chw_flow_sensor.type_uri() # 'https://project-haystack.org/def/phIoT/3.9.10#chilled-water-flow-sensor'

# Generate an id for the point and bind it to a namespace
chw_flow_sensor.set_id() # UUID('2733f091-be5b-4983-b701-b7e42c52b72c')
chw_flow_sensor.set_namespace(EX) # True

# Add the entity to the graph hg
chw_flow_sensor.bind_to_graph(hg)

Examples

Jupyter Lab is currently a dev dependency. If you have gone through the poetry setup, run:

Developing

Recommended setup documented here

tasty's People

Contributors

corymosiman12 avatar matthewsteen avatar aviveiros11 avatar tshapinsky avatar

Stargazers

 avatar PT Elliott avatar  avatar

Watchers

James Cloos avatar National Renewable Energy Laboratory avatar  avatar  avatar Avijit Saha avatar  avatar  avatar  avatar

tasty's Issues

fix merge.py

@gtfierro I got this error when running merge.py. This was after going through the HIL merging process.

Traceback (most recent call last):
  File "merge.py", line 19, in <module>
    G = merge_type_cluster(g1, g2, BLDG, similarity_threshold=0.1)
  File "/home/ubuntu20/.local/lib/python3.8/site-packages/brickschema/merge.py", line 237, in merge_type_cluster
    linked_records, leftover_g1, leftover_g2 = _merge_features(
  File "/home/ubuntu20/.local/lib/python3.8/site-packages/brickschema/merge.py", line 186, in _merge_features
    linked_entities = _unpack_linked_records(linked_records)
  File "/home/ubuntu20/.local/lib/python3.8/site-packages/brickschema/merge.py", line 35, in _unpack_linked_records
    for (e1, e2), _ in linked_records:
ValueError: too many values to unpack (expected 2)

Refactor Name

Refactor name from Tasty to an agreed-upon package name

Refine README

Complete and follow a standard convention for the README in anticipation of publishing the package.

Add version to nrel.json

Steve recommended using an 0.0.4-beta version, so let's change the prefix to:

https://project-haystack.org/datashapes/nrel/0.0.4-beta#

AHU tab template integration from the NREL BAS naming conventions spreadsheet

Convert the following equipment profiles to tasty templates and generate shapes from them for validation:

  • AHU-VAV-MZ w/ Relief, Return Fan, HW (with pump) Heat, CHW (with pump) + Econ + Evap Cool
  • AHU-VAV-SZ Heat Pump (Cool/Heat) + Electric Backup, Econ Cool
  • AHU-VAV-MZ w/ Relief, Relief Fan, Heat Pump (Cool/Heat) + Electric Backup, Econ Cool

Enable shape library to import other shape libraries

haystack_nrel.json should be able to simply reuse shapes from haystack_core_v2.json. The hope being that many reusable shapes can be defined in the core libraries and users can create new shapes while reusing existing shapes.

ASHRAE 223p integration

Check the status of 223p development and begin to develop tasty templates from strike team bravo

Develop unit tests

Write test cases for each example validation in the repository modularly:

  • Point validation
  • Equip validation
  • System validation

Data type validation

Include the ability to validate instance-level shapes when values are present. Adjacent to point-level validation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.