Skip to main content

Data models for EnergyPlus automatically generated from EnergyPlus JSON schema using datamodel-code-generator.

Project description

epmodel

epmodel is a pydantic (V2) data model for EnergyPlus modeling. The data model code itself is automatically generated from the EnergyPlus JSON schema using the datamodel-code-generator package.

Usage

Due to the size of the official EnergyPlus JSON schema, we reduce the data model scope down the a few commonly used ones. The name of these data models are list in the keys.txt file, which is also used to generate the data model code.

Expanding the scope of data model

We can add object to the data model by adding names directly to the keys.txt file.

Generate the source code

To generate the source code, run the following command inside the codegen directory:

python codegen.py

As a result, a src/epmodel/model.py file will be a generated with the data model code.

Using the data model

Using the data model object is as simple as:

import json
from epmodel import EnergyPlusModel

with open("model.epJSON", "r") as f:
    data = json.load(f)
model = EnergyPlusModel.model_validate(data)

The code above loads in the EnergyPlus epJSON model and validate it against the data model. If the mode is valid, a EnergyPlusModel object will be returned, otherwise, an ValidationError will be raised.

One of the benefits of having such data model, beyond data validation, is that we can use autocomplete in IDE to help use write the code.

Dependencies

Dependency for code generation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

epmodel-0.2.5.tar.gz (58.3 kB view details)

Uploaded Source

Built Distribution

epmodel-0.2.5-py3-none-any.whl (57.3 kB view details)

Uploaded Python 3

File details

Details for the file epmodel-0.2.5.tar.gz.

File metadata

  • Download URL: epmodel-0.2.5.tar.gz
  • Upload date:
  • Size: 58.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for epmodel-0.2.5.tar.gz
Algorithm Hash digest
SHA256 4beff8fd2f66d8498123e653cf112ef380e97485cce40ca00aedb5fbddbc7158
MD5 b7cb1118213429405bd351120410fab4
BLAKE2b-256 ba51c5bc1829c205efc7879f65404fed88fcd35c3746b624f5543424c3789546

See more details on using hashes here.

File details

Details for the file epmodel-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: epmodel-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 57.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for epmodel-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 258bc6e9b785aa176d023fd7e4bc47e9e4644b5298c73e1552e81756a14d7e7c
MD5 2ccf46d6043628e31e959fdb964044e1
BLAKE2b-256 6cd12f915e7d986a7649446347ef15a7d49431e48a3c148db1ae8f16a1f9437e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page