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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

epmodel-0.8.0-py3-none-any.whl (60.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: epmodel-0.8.0.tar.gz
  • Upload date:
  • Size: 61.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for epmodel-0.8.0.tar.gz
Algorithm Hash digest
SHA256 ec268f06ccc7e36fa661f2d067b2f0d4c9f0de9a22f52af4be9f274ac28aa25c
MD5 ceaabb440c2017fcc5236aacfe2b7ab6
BLAKE2b-256 ccbaa713bb6b59597957e8371d20d12a451867abe04bb72af526fba7777d8632

See more details on using hashes here.

File details

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

File metadata

  • Download URL: epmodel-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 60.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for epmodel-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3504f5150e0b75fef53c603c010b72754f93daf1201e50c4fcb1f0ba65fffd1c
MD5 3653d6ca09165b65721e3b3d623f843f
BLAKE2b-256 3216bd09b815731e07ca4aa4171e242910090a13bf374268257e8ead57279ac1

See more details on using hashes here.

Supported by

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