Schema¶
EpJSONSchema wraps the official Energy+.schema.epJSON file and exposes
field metadata -- types, defaults, ranges, reference lists, and extensible
group info.
SchemaManager handles version discovery, caching, and lazy loading of
schema files.
EpJSON Schema loader and manager.
Handles loading and caching of Energy+.schema.epJSON files for different EnergyPlus versions. Supports both uncompressed and gzip-compressed schema files.
EpJSONSchema
¶
Wrapper around Energy+.schema.epJSON providing easy access to object definitions.
The schema contains: - Object definitions with field types, defaults, constraints - Reference lists (object-list) for cross-object validation - Legacy IDD info for IDF field ordering
Examples:
>>> from idfkit import get_schema, LATEST_VERSION
>>> schema = get_schema(LATEST_VERSION)
>>> "Zone" in schema
True
Check which IDD group a type belongs to:
Some object types (like Timestep) are singletons with no name field:
Attributes:
| Name | Type | Description |
|---|---|---|
version |
tuple[int, int, int]
|
The EnergyPlus version tuple |
_raw |
dict[str, Any]
|
The raw schema dict |
_properties |
dict[str, Any]
|
Object definitions |
Source code in src/idfkit/schema.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
object_types
property
¶
__contains__(obj_type)
¶
__len__()
¶
get_all_field_names(obj_type)
¶
Get all field names including 'name'.
Source code in src/idfkit/schema.py
get_extensible_field_names(obj_type)
¶
Get extensible field names from legacy_idd.extensibles.
Source code in src/idfkit/schema.py
get_extensible_size(obj_type)
¶
Get the extensible group size for an object type.
get_field_default(obj_type, field_name)
¶
Get default value for a field.
get_field_names(obj_type)
¶
Get ordered list of field names for an object type (from legacy_idd).
Useful for discovering valid field names when building objects programmatically.
Examples:
List the fields available on a Material object:
>>> from idfkit import get_schema, LATEST_VERSION
>>> schema = get_schema(LATEST_VERSION)
>>> "thickness" in schema.get_field_names("Material")
True
Source code in src/idfkit/schema.py
get_field_object_list(obj_type, field_name)
¶
Get the object_list(s) that a field references.
Source code in src/idfkit/schema.py
get_field_schema(obj_type, field_name)
¶
Get schema for a specific field of an object type.
Source code in src/idfkit/schema.py
get_field_type(obj_type, field_name)
¶
Get the type of a field ('number', 'string', 'integer', 'array').
Useful for dynamic type coercion when importing data from spreadsheets or CSV files.
Examples:
>>> from idfkit import get_schema, LATEST_VERSION
>>> schema = get_schema(LATEST_VERSION)
>>> schema.get_field_type("Material", "thickness")
'number'
>>> schema.get_field_type("Material", "roughness")
'string'
Source code in src/idfkit/schema.py
get_group(obj_type)
¶
Get the IDD group name for an object type.
Every object type in the EnergyPlus schema belongs to a group
(e.g. "Thermal Zones and Surfaces", "HVAC Templates",
"Detailed Ground Heat Transfer"). This method returns the
group string, which is useful for classifying objects without
relying on naming conventions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj_type
|
str
|
Case-sensitive EnergyPlus object type
(e.g. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The group name, or |
Examples:
schema = get_schema((24, 1, 0))
schema.get_group("Zone")
# "Thermal Zones and Surfaces"
schema.get_group("HVACTemplate:Zone:IdealLoadsAirSystem")
# "HVAC Templates"
Source code in src/idfkit/schema.py
get_inner_schema(obj_type)
¶
Get the inner schema (inside patternProperties) for an object type.
Source code in src/idfkit/schema.py
get_object_memo(obj_type)
¶
Get the memo/description for an object type.
get_object_schema(obj_type)
¶
Get the full schema for an object type.
Examples:
>>> from idfkit import get_schema, LATEST_VERSION
>>> schema = get_schema(LATEST_VERSION)
>>> zone_schema = schema.get_object_schema("Zone")
>>> zone_schema is not None
True
>>> schema.get_object_schema("NonExistent") is None
True
Source code in src/idfkit/schema.py
get_parsing_cache(obj_type)
¶
Get or lazily build pre-computed parsing metadata for an object type.
Returns None if obj_type is not in the schema.
Source code in src/idfkit/schema.py
get_required_fields(obj_type)
¶
Get list of required field names for an object type.
Check which fields must be supplied before a Material is valid:
Examples:
>>> from idfkit import get_schema, LATEST_VERSION
>>> schema = get_schema(LATEST_VERSION)
>>> schema.get_required_fields("Material")
['roughness', 'thickness', 'conductivity', 'density', 'specific_heat']
Source code in src/idfkit/schema.py
get_types_providing_reference(ref_list)
¶
has_name(obj_type)
¶
Check if an object type has a name field (first IDF field is a name).
Source code in src/idfkit/schema.py
is_extensible(obj_type)
¶
Check if an object type has extensible fields.
Extensible types (like surfaces) can have a variable number of vertices or layers.
Examples:
>>> from idfkit import get_schema, LATEST_VERSION
>>> schema = get_schema(LATEST_VERSION)
>>> schema.is_extensible("BuildingSurface:Detailed")
True
>>> schema.is_extensible("Zone")
False
Source code in src/idfkit/schema.py
is_reference_field(obj_type, field_name)
¶
ParsingCache
dataclass
¶
Pre-computed parsing metadata for a single object type.
Built lazily on first access per object type and cached for reuse. Eliminates repeated nested dict traversals during parsing.
Source code in src/idfkit/schema.py
SchemaManager
¶
Manages loading and caching of EpJSON schemas for different versions.
Searches for schemas in the following order: 1. Bundled schemas directory (shipped with idfkit) - both .gz and plain 2. User cache directory (~/.idfkit/schemas/) 3. EnergyPlus installation directories
Supports gzip-compressed schema files (.epJSON.gz) to reduce package size.
Source code in src/idfkit/schema.py
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 | |
bundled_dir
property
¶
Path to the bundled schemas directory.
cache_dir
property
¶
Path to the user cache directory for schemas.
__init__(bundled_schema_dir=None, cache_dir=None)
¶
Initialize the schema manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bundled_schema_dir
|
Path | None
|
Path to directory with bundled schema files. If None, uses default location next to this file. |
None
|
cache_dir
|
Path | None
|
Path to user cache directory for downloaded schemas. If None, uses ~/.idfkit/schemas/. |
None
|
Source code in src/idfkit/schema.py
clear_cache()
¶
get_available_versions()
¶
Get list of versions with available schemas.
Checks bundled schemas, user cache, and installed EnergyPlus versions.
Source code in src/idfkit/schema.py
get_schema(version)
cached
¶
Load and return schema for a specific version.
If the exact version is not found, attempts to find the closest supported version that is <= the requested version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
tuple[int, int, int]
|
EnergyPlus version tuple (major, minor, patch) |
required |
Returns:
| Type | Description |
|---|---|
EpJSONSchema
|
EpJSONSchema for the requested version |
Raises:
| Type | Description |
|---|---|
SchemaNotFoundError
|
If schema cannot be found |
Source code in src/idfkit/schema.py
get_supported_versions()
¶
Get list of all EnergyPlus versions that idfkit supports.
This returns all versions in the registry, regardless of whether schema files are currently available locally.
Source code in src/idfkit/schema.py
get_schema(version)
¶
Convenience function to get schema for a version.
Examples:
>>> from idfkit import get_schema, LATEST_VERSION
>>> schema = get_schema(LATEST_VERSION)
>>> "Zone" in schema
True
>>> schema = get_schema((24, 1, 0))
>>> schema.version
(24, 1, 0)
Source code in src/idfkit/schema.py
get_schema_manager()
¶
load_schema_json(path)
¶
Load a schema JSON file, handling both plain and gzip-compressed files.