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

Uploaded Source

Built Distribution

epmodel-0.3.0-py3-none-any.whl (57.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for epmodel-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a9f3b88626e412ec4420cece388964f835aee8e10abd7fd95430773afde6becb
MD5 4a99fbfdc78847b566c465adc3b35fa2
BLAKE2b-256 8e0662ce36c91e6afe805431f9a7892d92c7cc1d1cb6ee70310f7a17348d53d5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: epmodel-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 57.2 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87d76913d70c0f501e34a40f969e9e9008e6fd1bdc4d166aba93842ab825b3fc
MD5 f638daf88844cc9109ccbda6a10e45c9
BLAKE2b-256 29d003290693e1c02d658a0fb517d6735bffec086eff65fa98f04b37c3ddc219

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