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:
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file epmodel-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: epmodel-0.1.0-py3-none-any.whl
- Upload date:
- Size: 53.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 702ccd1694f37d416f0901945422b2f202c2e6b087f630ec5849acc27c41c7d5 |
|
MD5 | c59719427f326a417670abc9016831be |
|
BLAKE2b-256 | a65a11a3a6d1ea96ba9d3457b37850413799cd33e416cb8cd679f5061d656972 |