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.7.1.tar.gz (60.9 kB view details)

Uploaded Source

Built Distribution

epmodel-0.7.1-py3-none-any.whl (60.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: epmodel-0.7.1.tar.gz
  • Upload date:
  • Size: 60.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for epmodel-0.7.1.tar.gz
Algorithm Hash digest
SHA256 57cdd4b4be50d3604341bc06e5f7fae4b9c700bee73e3173324c593019944d40
MD5 16c3594d1a2378248a62ce77eea22b4a
BLAKE2b-256 37b1a942eb29fc7c97e99dfd36536d49e5646178610cd69e5adc9af0f4489338

See more details on using hashes here.

File details

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

File metadata

  • Download URL: epmodel-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 60.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for epmodel-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b91c680c6f53a5f13d7a5e02cafacc6d9b9a55c485b888f91d05a3ac8b6cc407
MD5 deb991a1d33978b12494435d29330c23
BLAKE2b-256 398d8b1e3965eb449963d0681c87117ded2586206f79ed348ba706f35cff97d1

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