Skip to content

Results API

Simulation result container and output file access.

SimulationResult

idfkit.simulation.result.SimulationResult dataclass

Result of an EnergyPlus simulation run.

The parsed-output accessors (sql, csv, eso, mtr, html, variables and their async_* counterparts) never return None: when the run produced no such file they raise OutputNotFoundError, whose message says which output object to add. Test for a file without raising with its path property, e.g. result.sql_path is None.

Attributes:

Name Type Description
run_dir Path

Directory containing all simulation output.

success bool

Whether the simulation exited successfully.

exit_code int | None

Process exit code (None if timed out).

stdout str

Captured standard output.

stderr str

Captured standard error.

runtime_seconds float

Wall-clock execution time in seconds.

output_prefix str

Output file prefix (default "eplus").

fs FileSystem | None

Optional sync file system backend for reading output files.

async_fs AsyncFileSystem | None

Optional async file system backend for non-blocking reads. Set automatically by async_simulate when an AsyncFileSystem is provided.

migration_report MigrationReport | None

Populated when simulate(..., auto_migrate=True) forward-migrated the model before running. None when no migration occurred.

output_suffix Literal['C', 'L', 'D'] | None

The run's --output-suffix style ("C", "L" or "D"), whose file names are looked up first. None when unknown, which tries the default "C" names first.

refusal str | None

Why a batch job produced no simulation result: the message of the exception simulate raised for it before EnergyPlus wrote to run_dir (a refused request, EnergyPlus not found, a failed preprocessor or upload). None for every result simulate returned, and for a job that raised after EnergyPlus ran in its output_dir (a timeout), whose result reads that run's outputs. A refused result reads no files from run_dir; its errors hold one fatal message with this reason.

cached bool

True when the result came from a SimulationCache hit instead of a fresh EnergyPlus run. With an output_dir the hit's files are copied there, so writing into run_dir never touches the cache entry; without one, run_dir is the cache entry itself and must be treated as read-only. runtime_seconds and exit_code are those of the run that filled the entry, and stdout/stderr are empty.

owns_run_dir bool

True when idfkit created run_dir as a temporary directory for this result, which simulate() and async_simulate() do when called without an output_dir. Only then do cleanup and the with / async with blocks delete it. False for a caller's output_dir, a remote fs directory and a cache entry, which are never deleted.

cancelled bool

True for a batch job that fail_fast=True cancelled after another job failed: it never started, or its EnergyPlus run was killed. Such a result is failed, and like a refused one carries the reason in refusal and reads no files from run_dir. BatchResult.cancelled lists them.

Source code in idfkit/simulation/result.py
 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
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 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
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
@dataclass(slots=True)
class SimulationResult:
    """Result of an EnergyPlus simulation run.

    The parsed-output accessors (``sql``, ``csv``, ``eso``, ``mtr``, ``html``, ``variables`` and
    their ``async_*`` counterparts) never return ``None``: when the run produced no such file they
    raise [OutputNotFoundError][idfkit.exceptions.OutputNotFoundError], whose message says which
    output object to add. Test for a file without raising with its path property, e.g.
    ``result.sql_path is None``.

    Attributes:
        run_dir: Directory containing all simulation output.
        success: Whether the simulation exited successfully.
        exit_code: Process exit code (None if timed out).
        stdout: Captured standard output.
        stderr: Captured standard error.
        runtime_seconds: Wall-clock execution time in seconds.
        output_prefix: Output file prefix (default "eplus").
        fs: Optional sync file system backend for reading output files.
        async_fs: Optional async file system backend for non-blocking reads.
            Set automatically by [async_simulate][idfkit.simulation.async_runner.async_simulate] when an
            [AsyncFileSystem][idfkit.simulation.fs.AsyncFileSystem] is provided.
        migration_report: Populated when ``simulate(..., auto_migrate=True)``
            forward-migrated the model before running. ``None`` when no
            migration occurred.
        output_suffix: The run's ``--output-suffix`` style (``"C"``, ``"L"``
            or ``"D"``), whose file names are looked up first. ``None`` when
            unknown, which tries the default ``"C"`` names first.
        refusal: Why a batch job produced no simulation result: the message
            of the exception ``simulate`` raised for it before EnergyPlus wrote
            to ``run_dir`` (a refused request, EnergyPlus not found, a failed
            preprocessor or upload). ``None`` for every result ``simulate``
            returned, and for a job that raised after EnergyPlus ran in its
            ``output_dir`` (a timeout), whose result reads that run's outputs. A refused result reads
            no files from ``run_dir``; its ``errors`` hold one fatal message
            with this reason.
        cached: ``True`` when the result came from a
            [SimulationCache][idfkit.simulation.cache.SimulationCache] hit
            instead of a fresh EnergyPlus run. With an ``output_dir`` the
            hit's files are copied there, so writing into ``run_dir`` never
            touches the cache entry; without one, ``run_dir`` is the cache
            entry itself and must be treated as read-only.
            ``runtime_seconds`` and ``exit_code`` are those of the run that
            filled the entry, and ``stdout``/``stderr`` are empty.
        owns_run_dir: ``True`` when idfkit created ``run_dir`` as a temporary
            directory for this result, which ``simulate()`` and
            ``async_simulate()`` do when called without an ``output_dir``.
            Only then do [cleanup][idfkit.simulation.result.SimulationResult.cleanup]
            and the ``with`` / ``async with`` blocks delete it. ``False`` for a
            caller's ``output_dir``, a remote ``fs`` directory and a cache entry,
            which are never deleted.
        cancelled: ``True`` for a batch job that ``fail_fast=True`` cancelled
            after another job failed: it never started, or its EnergyPlus run
            was killed. Such a result is failed, and like a refused one carries
            the reason in ``refusal`` and reads no files from ``run_dir``.
            [BatchResult.cancelled][idfkit.simulation.batch.BatchResult.cancelled]
            lists them.
    """

    run_dir: Path
    success: bool
    exit_code: int | None
    stdout: str = field(repr=False)
    stderr: str = field(repr=False)
    runtime_seconds: float
    output_prefix: str = "eplus"
    fs: FileSystem | None = field(default=None, repr=False)
    async_fs: AsyncFileSystem | None = field(default=None, repr=False)
    migration_report: MigrationReport | None = field(default=None, repr=False)
    output_suffix: Literal["C", "L", "D"] | None = field(default=None, repr=False)
    refusal: str | None = None
    cached: bool = False
    owns_run_dir: bool = field(default=False, repr=False)
    cancelled: bool = False
    _cached_errors: Any = field(default=_UNSET, init=False, repr=False)
    _cached_sql: Any = field(default=_UNSET, init=False, repr=False)
    _cached_variables: Any = field(default=_UNSET, init=False, repr=False)
    _cached_csv: Any = field(default=_UNSET, init=False, repr=False)
    _cached_html: Any = field(default=_UNSET, init=False, repr=False)
    _cached_eso: Any = field(default=_UNSET, init=False, repr=False)
    _cached_mtr: Any = field(default=_UNSET, init=False, repr=False)

    def __post_init__(self) -> None:
        if self.fs is not None and self.async_fs is not None:
            msg = "fs and async_fs are mutually exclusive — provide one or neither"
            raise ValueError(msg)

    def __repr__(self) -> str:
        if self.refusal is not None:
            kind = "cancelled" if self.cancelled else "refused"
            return f"SimulationResult({kind}: {self.refusal!r}, run_dir={self.run_dir!r})"
        return (
            f"SimulationResult(run_dir={self.run_dir!r}, success={self.success!r}, exit_code={self.exit_code!r}, "
            f"runtime_seconds={self.runtime_seconds!r}, output_prefix={self.output_prefix!r}"
            + (", cached=True)" if self.cached else ")")
        )

    def close(self) -> None:
        """Release any open file handles held by cached parsers.

        Closes the SQLite connection opened lazily by [sql][idfkit.simulation.result.SimulationResult.sql] /
        [async_sql][idfkit.simulation.result.SimulationResult.async_sql] (and removes the temporary copy made
        for remote file systems). The other parsers read their files eagerly
        and hold no handles, so this is currently a no-op for them.

        Call this before deleting the run directory yourself. On Windows an
        open SQLite connection locks ``eplus.sql`` and blocks ``shutil.rmtree``
        / ``TemporaryDirectory`` cleanup with ``PermissionError [WinError 32]``.
        Safe to call more than once; the cached connection is reopened on next
        access if needed. Leaves ``run_dir`` in place; see
        [cleanup][idfkit.simulation.result.SimulationResult.cleanup] to delete it.
        """
        cached = object.__getattribute__(self, "_cached_sql")
        if cached is not _UNSET:
            cached.close()
        object.__setattr__(self, "_cached_sql", _UNSET)

    def cleanup(self) -> None:
        """Close open handles and delete ``run_dir`` if idfkit created it.

        ``simulate()`` without an ``output_dir`` runs EnergyPlus in a new
        temporary directory, which nothing deletes on its own because the
        output accessors read their files from it lazily. This deletes it once
        you are done with the result. A caller-supplied ``output_dir``, a remote
        ``fs`` directory and a cache entry are never touched
        ([owns_run_dir][idfkit.simulation.result.SimulationResult.owns_run_dir]
        is ``False`` for them): for those this only calls
        [close][idfkit.simulation.result.SimulationResult.close].

        The SQLite connection is closed first, so the delete is not blocked by
        a file lock on Windows. Read what you need before calling it: an output
        not parsed before the delete can no longer be read. Safe to call more
        than once.

        Using the result as a context manager calls this on exit::

            with simulate(model, "weather.epw") as result:
                print(result.errors.summary())
            # the temporary run directory is gone here

        Raises:
            OSError: If the directory exists and cannot be deleted.
        """
        self.close()
        if self.owns_run_dir:
            self._remove_run_dir()

    def _remove_run_dir(self) -> None:
        if self.run_dir.exists():
            shutil.rmtree(self.run_dir)

    async def async_cleanup(self) -> None:
        """Close open handles and delete ``run_dir`` if idfkit created it (async).

        Non-blocking counterpart to
        [cleanup][idfkit.simulation.result.SimulationResult.cleanup]: the delete
        runs in a worker thread. ``async with`` calls this on exit.
        """
        # Close on the calling thread: sqlite3 refuses to close a connection from a
        # thread other than the one that opened it, which would leave the file locked.
        self.close()
        if self.owns_run_dir:
            await asyncio.to_thread(self._remove_run_dir)

    def __enter__(self) -> SimulationResult:
        return self

    def __exit__(self, *exc: object) -> None:
        self.cleanup()

    async def __aenter__(self) -> SimulationResult:
        return self

    async def __aexit__(self, *exc: object) -> None:
        await self.async_cleanup()

    def raise_for_status(self) -> SimulationResult:
        """Raise if the run failed; return this result if it succeeded.

        ``simulate()`` reports a failed run in the result rather than raising, so a caller that
        wants to stop on failure calls this: ``result = simulate(doc, epw).raise_for_status()``.

        Returns:
            This result, when [success][idfkit.simulation.result.SimulationResult.success] is true.

        Raises:
            SimulationError: If the run failed. Its message names the ``.err`` file and quotes the
                fatal and first severe errors; its ``result`` is this result.
            RuntimeError: If the result reads its files through an ``AsyncFileSystem``; use
                [async_raise_for_status][idfkit.simulation.result.SimulationResult.async_raise_for_status].
        """
        if self.success:
            return self
        raise self._failure(self.errors, self.err_path)

    async def async_raise_for_status(self) -> SimulationResult:
        """Raise if the run failed; return this result if it succeeded (async).

        Non-blocking counterpart to [raise_for_status][idfkit.simulation.result.SimulationResult.raise_for_status].

        Raises:
            SimulationError: If the run failed.
        """
        if self.success:
            return self
        report = await self.async_errors()
        raise self._failure(report, await self._async_find_output_file(".err"))

    def _failure(self, report: ErrorReport, err_path: Path | None) -> SimulationError:
        """The error [raise_for_status][idfkit.simulation.result.SimulationResult.raise_for_status] raises for this
        failed run."""
        if self.refusal is not None:
            msg = f"Simulation {'cancelled' if self.cancelled else 'refused'}: {self.refusal}"
            # A stderr that only restates the reason (the exception's own message) is not repeated.
            stderr = self.stderr if self.stderr and self.refusal not in self.stderr else None
            return SimulationError(msg, exit_code=self.exit_code, stderr=stderr, result=self)
        msg = "EnergyPlus simulation failed"
        if report.error_count:
            msg += f"\n{report.summary()}"
        if err_path is not None:
            msg += f"\nFull error report: {err_path}"
        # Without errors in the .err file (a timeout, a crash), stderr says why.
        stderr = None if report.error_count else self.stderr or None
        return SimulationError(msg, exit_code=self.exit_code, stderr=stderr, result=self)

    def _missing_output(self, output: str) -> OutputNotFoundError:
        """The error a parsed-output accessor raises when its file is missing."""
        err_path = self.err_path if not self.success and self.refusal is None else None
        return self._output_error(output, err_path)

    async def _async_missing_output(self, output: str) -> OutputNotFoundError:
        """Async counterpart to `_missing_output`: looks the ``.err`` file up without blocking."""
        failed = not self.success and self.refusal is None
        err_path = await self._async_find_output_file(".err") if failed else None
        return self._output_error(output, err_path)

    def _output_error(self, output: str, err_path: Path | None) -> OutputNotFoundError:
        """Build the actionable `OutputNotFoundError` for *output* (an accessor name)."""
        hint = _OUTPUT_HINTS[output]
        if self.cancelled:
            msg = (
                f"No {hint.file}: this batch job was cancelled ({self.refusal}). "
                "result.raise_for_status() raises with the reason."
            )
        elif self.refusal is not None:
            msg = (
                f"No {hint.file}: this job was refused before EnergyPlus ran ({self.refusal}). "
                "result.raise_for_status() raises with the reason."
            )
        elif not self.success:
            msg = (
                f"No {hint.file} in {self.run_dir}: the simulation failed. "
                "Call result.raise_for_status() or read result.errors"
            )
            msg += f" (full error report: {err_path})." if err_path is not None else "."
        else:
            msg = (
                f"No {hint.file} in {self.run_dir}. To get one, {hint.remedy}. "
                f"To test for it without raising, check result.{hint.path_property} is None."
            )
        return OutputNotFoundError(msg, output=output, run_dir=self.run_dir)

    @property
    def errors(self) -> ErrorReport:
        """Parsed error report from the .err file (lazily cached).

        Returns:
            Parsed ErrorReport from the simulation's .err output.
        """
        cached = object.__getattribute__(self, "_cached_errors")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        err = self.err_path
        if self.refusal is not None:
            report = _refusal_report(self.refusal, cancelled=self.cancelled)
        elif err is None:
            report = ErrorReport.from_string("")
        elif self.fs is not None:
            text = self.fs.read_text(str(err), encoding="latin-1")
            report = ErrorReport.from_string(text)
        else:
            report = ErrorReport.from_file(err)
        object.__setattr__(self, "_cached_errors", report)
        return report

    @property
    def sql(self) -> SQLResult:
        """Parsed SQL output database (lazily cached).

        Returns:
            An SQLResult for querying time-series and tabular data.

        Raises:
            OutputNotFoundError: If the run produced no .sql file. The message names the output
                object to add, or how to read why the run failed. Check ``sql_path is None``
                to test for the file without raising.
        """
        cached = object.__getattribute__(self, "_cached_sql")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        path = self.sql_path
        if path is None:
            raise self._missing_output("sql")
        from .parsers.sql import SQLResult as _SQLResult

        if self.fs is not None:
            # sqlite3 requires a local file — download to a temp file
            data = self.fs.read_bytes(str(path))
            with tempfile.NamedTemporaryFile(suffix=".sql", delete=False) as tmp_file:
                tmp_file.write(data)
            result: SQLResult = _SQLResult(Path(tmp_file.name), _owns_file=True)
        else:
            result = _SQLResult(path)
        object.__setattr__(self, "_cached_sql", result)
        return result

    @property
    def variables(self) -> OutputVariableIndex:
        """Output variable/meter index from .rdd/.mdd files (lazily cached).

        Returns:
            An OutputVariableIndex for searching and injecting output
            variables.

        Raises:
            OutputNotFoundError: If the run produced no .rdd file. The message names the output
                object to add, or how to read why the run failed. Check ``rdd_path is None``
                to test for the file without raising.
        """
        cached = object.__getattribute__(self, "_cached_variables")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        rdd = self.rdd_path
        if rdd is None:
            raise self._missing_output("variables")

        if self.fs is not None:
            from .parsers.rdd import parse_mdd, parse_rdd

            rdd_text = self.fs.read_text(str(rdd), encoding="latin-1")
            variables = parse_rdd(rdd_text)
            mdd = self.mdd_path
            meters = parse_mdd(self.fs.read_text(str(mdd), encoding="latin-1")) if mdd is not None else ()
            from .outputs import OutputVariableIndex as _OutputVariableIndex

            result: OutputVariableIndex = _OutputVariableIndex(variables=variables, meters=meters)
        else:
            from .outputs import OutputVariableIndex as _OutputVariableIndex

            result = _OutputVariableIndex.from_files(rdd, self.mdd_path)
        object.__setattr__(self, "_cached_variables", result)
        return result

    @property
    def csv(self) -> CSVResult:
        """Parsed CSV output (lazily cached).

        Returns:
            A CSVResult with extracted column metadata and values.

        Raises:
            OutputNotFoundError: If the run produced no .csv file. The message names the output
                object to add, or how to read why the run failed. Check ``csv_path is None``
                to test for the file without raising.
        """
        cached = object.__getattribute__(self, "_cached_csv")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        path = self.csv_path
        if path is None:
            raise self._missing_output("csv")
        from .parsers.csv import CSVResult as _CSVResult

        if self.fs is not None:
            text = self.fs.read_text(str(path), encoding="latin-1")
            result: CSVResult = _CSVResult.from_string(text)
        else:
            result = _CSVResult.from_file(path)
        object.__setattr__(self, "_cached_csv", result)
        return result

    @property
    def html(self) -> HTMLResult:
        """Parsed HTML tabular output (lazily cached).

        Returns:
            An HTMLResult with extracted tables and titles.

        Raises:
            OutputNotFoundError: If the run produced no HTML table report. The message names the output
                object to add, or how to read why the run failed. Check ``html_path is None``
                to test for the file without raising.
        """
        cached = object.__getattribute__(self, "_cached_html")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        path = self.html_path
        if path is None:
            raise self._missing_output("html")
        from .parsers.html import HTMLResult as _HTMLResult

        if self.fs is not None:
            text = self.fs.read_text(str(path), encoding="latin-1")
            result: HTMLResult = _HTMLResult.from_string(text)
        else:
            result = _HTMLResult.from_file(path)
        object.__setattr__(self, "_cached_html", result)
        return result

    def _load_eso_sync(self, path: Path) -> ESOResult:
        """Read and parse an ESO/MTR file from disk or the sync file system."""
        from .parsers.eso import ESOResult as _ESOResult

        if self.fs is not None:
            return _ESOResult.from_bytes(self.fs.read_bytes(str(path)))
        return _ESOResult.from_file(path)

    @property
    def eso(self) -> ESOResult:
        """Parsed ESO time-series output (lazily cached).

        Returns:
            An ESOResult for extracting variable time series.

        Raises:
            OutputNotFoundError: If the run produced no .eso file. The message names the output
                object to add, or how to read why the run failed. Check ``eso_path is None``
                to test for the file without raising.
        """
        cached = object.__getattribute__(self, "_cached_eso")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        path = self.eso_path
        if path is None:
            raise self._missing_output("eso")
        result = self._load_eso_sync(path)
        object.__setattr__(self, "_cached_eso", result)
        return result

    @property
    def mtr(self) -> ESOResult:
        """Parsed MTR meter time-series output (lazily cached).

        The .mtr meter file uses the same format as .eso, so it is parsed by the
        same reader.

        Returns:
            An ESOResult for extracting meter time series.

        Raises:
            OutputNotFoundError: If the run produced no .mtr file. The message names the output
                object to add, or how to read why the run failed. Check ``mtr_path is None``
                to test for the file without raising.
        """
        cached = object.__getattribute__(self, "_cached_mtr")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        path = self.mtr_path
        if path is None:
            raise self._missing_output("mtr")
        result = self._load_eso_sync(path)
        object.__setattr__(self, "_cached_mtr", result)
        return result

    @property
    def sql_path(self) -> Path | None:
        """Path to the SQLite output file, if present."""
        return self._find_output_file(".sql")

    @property
    def err_path(self) -> Path | None:
        """Path to the .err output file, if present."""
        return self._find_output_file(".err")

    @property
    def eso_path(self) -> Path | None:
        """Path to the .eso output file, if present."""
        return self._find_output_file(".eso")

    @property
    def mtr_path(self) -> Path | None:
        """Path to the .mtr meter output file, if present."""
        return self._find_output_file(".mtr")

    @property
    def csv_path(self) -> Path | None:
        """Path to the .csv output file, if present."""
        return self._find_output_file(".csv")

    @property
    def html_path(self) -> Path | None:
        """Path to the HTML tabular output file, if present."""
        return self._find_output_file(".htm", table=True) or self._find_output_file(".html", table=True)

    @property
    def rdd_path(self) -> Path | None:
        """Path to the .rdd output file, if present."""
        return self._find_output_file(".rdd")

    @property
    def mdd_path(self) -> Path | None:
        """Path to the .mdd output file, if present."""
        return self._find_output_file(".mdd")

    def _find_output_file(self, suffix: str, *, table: bool = False) -> Path | None:
        """Find an output file by suffix.

        Tries each name EnergyPlus gives the output for
        [output_prefix][idfkit.simulation.result.SimulationResult.output_prefix]
        (``{prefix}{suffix}``, then ``{prefix}out{suffix}``), then falls back to
        the first matching file of the run directory in name order, never an
        auxiliary output such as ``eplusSqlite.err``.

        Args:
            suffix: File suffix to look for (e.g. ".sql", ".err").
            table: Look for the tabular report (``{prefix}Table.htm`` and its
                other spellings) rather than a main output.

        Returns:
            Path to the file, or None if not found.

        Raises:
            RuntimeError: If only [async_fs][idfkit.simulation.result.SimulationResult.async_fs] is set (no sync access
                available).  Use the ``async_*`` methods instead.
        """
        if self.async_fs is not None and self.fs is None:
            msg = (
                "This SimulationResult was created with an AsyncFileSystem. "
                "Use the async accessors (e.g. async_errors(), async_sql()) "
                "instead of the sync properties."
            )
            raise RuntimeError(msg)

        if self.refusal is not None or self.run_dir == REFUSED_RUN_DIR:
            return None

        candidates = [
            self.run_dir / name
            for name in _output_names(self.output_prefix, suffix, table=table, style=self.output_suffix)
        ]

        if self.fs is not None:
            fs = self.fs
            for candidate in candidates:
                if fs.exists(str(candidate)):
                    return candidate
            return _pick_fallback(fs.glob(str(self.run_dir), f"*{suffix}"), suffix, table=table)

        # Local path-based lookup
        for candidate in candidates:
            if candidate.is_file():
                return candidate

        return self._scan_run_dir(suffix, table=table)

    def _scan_run_dir(self, suffix: str, *, table: bool = False) -> Path | None:
        """Return the local run directory's fallback file for *suffix*, if any."""
        files = (p for p in self.run_dir.iterdir() if p.name.endswith(suffix) and p.is_file())
        return _pick_fallback(files, suffix, table=table)

    # ------------------------------------------------------------------
    # Async accessors — non-blocking counterparts to the sync properties
    # ------------------------------------------------------------------

    async def async_errors(self) -> ErrorReport:
        """Parsed error report from the .err file (async, lazily cached).

        Non-blocking counterpart to [errors][idfkit.simulation.result.SimulationResult.errors] that uses
        [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

        Returns:
            Parsed ErrorReport from the simulation's .err output.
        """
        cached = object.__getattribute__(self, "_cached_errors")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        err = await self._async_find_output_file(".err")
        if self.refusal is not None:
            report = _refusal_report(self.refusal, cancelled=self.cancelled)
        elif err is None:
            report = ErrorReport.from_string("")
        elif self.async_fs is not None:
            text = await self.async_fs.read_text(str(err), encoding="latin-1")
            report = ErrorReport.from_string(text)
        elif self.fs is not None:
            text = self.fs.read_text(str(err), encoding="latin-1")
            report = ErrorReport.from_string(text)
        else:
            report = ErrorReport.from_file(err)
        object.__setattr__(self, "_cached_errors", report)
        return report

    async def async_sql(self) -> SQLResult:
        """Parsed SQL output database (async, lazily cached).

        Non-blocking counterpart to [sql][idfkit.simulation.result.SimulationResult.sql] that uses
        [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

        Returns:
            An SQLResult for querying time-series and tabular data.

        Raises:
            OutputNotFoundError: If the run produced no .sql file. The message names the output
                object to add, or how to read why the run failed. Check ``sql_path is None``
                to test for the file without raising.
        """
        cached = object.__getattribute__(self, "_cached_sql")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        path = await self._async_find_output_file(".sql")
        if path is None:
            raise await self._async_missing_output("sql")
        from .parsers.sql import SQLResult as _SQLResult

        if self.async_fs is not None:
            data = await self.async_fs.read_bytes(str(path))
            with tempfile.NamedTemporaryFile(suffix=".sql", delete=False) as tmp_file:
                tmp_file.write(data)
            result: SQLResult = _SQLResult(Path(tmp_file.name), _owns_file=True)
        elif self.fs is not None:
            data = self.fs.read_bytes(str(path))
            with tempfile.NamedTemporaryFile(suffix=".sql", delete=False) as tmp_file:
                tmp_file.write(data)
            result = _SQLResult(Path(tmp_file.name), _owns_file=True)
        else:
            result = _SQLResult(path)
        object.__setattr__(self, "_cached_sql", result)
        return result

    async def async_variables(self) -> OutputVariableIndex:
        """Output variable/meter index (async, lazily cached).

        Non-blocking counterpart to [variables][idfkit.simulation.result.SimulationResult.variables] that uses
        [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

        Returns:
            An OutputVariableIndex for searching and injecting output
            variables.

        Raises:
            OutputNotFoundError: If the run produced no .rdd file. The message names the output
                object to add, or how to read why the run failed. Check ``rdd_path is None``
                to test for the file without raising.
        """
        cached = object.__getattribute__(self, "_cached_variables")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        rdd = await self._async_find_output_file(".rdd")
        if rdd is None:
            raise await self._async_missing_output("variables")

        if self.async_fs is not None:
            from .parsers.rdd import parse_mdd, parse_rdd

            rdd_text = await self.async_fs.read_text(str(rdd), encoding="latin-1")
            variables = parse_rdd(rdd_text)
            mdd = await self._async_find_output_file(".mdd")
            meters = parse_mdd(await self.async_fs.read_text(str(mdd), encoding="latin-1")) if mdd is not None else ()
            from .outputs import OutputVariableIndex as _OutputVariableIndex

            result: OutputVariableIndex = _OutputVariableIndex(variables=variables, meters=meters)
        elif self.fs is not None:
            from .parsers.rdd import parse_mdd, parse_rdd

            rdd_text = self.fs.read_text(str(rdd), encoding="latin-1")
            variables = parse_rdd(rdd_text)
            mdd = self._find_output_file(".mdd")
            meters = parse_mdd(self.fs.read_text(str(mdd), encoding="latin-1")) if mdd is not None else ()
            from .outputs import OutputVariableIndex as _OutputVariableIndex

            result = _OutputVariableIndex(variables=variables, meters=meters)
        else:
            from .outputs import OutputVariableIndex as _OutputVariableIndex

            result = _OutputVariableIndex.from_files(rdd, self.mdd_path)
        object.__setattr__(self, "_cached_variables", result)
        return result

    async def async_csv(self) -> CSVResult:
        """Parsed CSV output (async, lazily cached).

        Non-blocking counterpart to [csv][idfkit.simulation.result.SimulationResult.csv] that uses
        [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

        Returns:
            A CSVResult with extracted column metadata and values.

        Raises:
            OutputNotFoundError: If the run produced no .csv file. The message names the output
                object to add, or how to read why the run failed. Check ``csv_path is None``
                to test for the file without raising.
        """
        cached = object.__getattribute__(self, "_cached_csv")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        path = await self._async_find_output_file(".csv")
        if path is None:
            raise await self._async_missing_output("csv")
        from .parsers.csv import CSVResult as _CSVResult

        if self.async_fs is not None:
            text = await self.async_fs.read_text(str(path), encoding="latin-1")
            result: CSVResult = _CSVResult.from_string(text)
        elif self.fs is not None:
            text = self.fs.read_text(str(path), encoding="latin-1")
            result = _CSVResult.from_string(text)
        else:
            result = _CSVResult.from_file(path)
        object.__setattr__(self, "_cached_csv", result)
        return result

    async def async_html(self) -> HTMLResult:
        """Parsed HTML tabular output (async, lazily cached).

        Non-blocking counterpart to [html][idfkit.simulation.result.SimulationResult.html] that uses
        [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

        Returns:
            An HTMLResult with extracted tables and titles.

        Raises:
            OutputNotFoundError: If the run produced no HTML table report. The message names the output
                object to add, or how to read why the run failed. Check ``html_path is None``
                to test for the file without raising.
        """
        cached = object.__getattribute__(self, "_cached_html")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        path = await self._async_find_output_file(".htm", table=True) or await self._async_find_output_file(
            ".html", table=True
        )
        if path is None:
            raise await self._async_missing_output("html")
        from .parsers.html import HTMLResult as _HTMLResult

        if self.async_fs is not None:
            text = await self.async_fs.read_text(str(path), encoding="latin-1")
            result: HTMLResult = _HTMLResult.from_string(text)
        elif self.fs is not None:
            text = self.fs.read_text(str(path), encoding="latin-1")
            result = _HTMLResult.from_string(text)
        else:
            result = _HTMLResult.from_file(path)
        object.__setattr__(self, "_cached_html", result)
        return result

    async def _load_eso_async(self, path: Path) -> ESOResult:
        """Read and parse an ESO/MTR file via the async/sync file system or disk."""
        from .parsers.eso import ESOResult as _ESOResult

        if self.async_fs is not None:
            return _ESOResult.from_bytes(await self.async_fs.read_bytes(str(path)))
        if self.fs is not None:
            return _ESOResult.from_bytes(self.fs.read_bytes(str(path)))
        return _ESOResult.from_file(path)

    async def async_eso(self) -> ESOResult:
        """Parsed ESO time-series output (async, lazily cached).

        Non-blocking counterpart to [eso][idfkit.simulation.result.SimulationResult.eso] that uses
        [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

        Returns:
            An ESOResult for extracting variable time series.

        Raises:
            OutputNotFoundError: If the run produced no .eso file. The message names the output
                object to add, or how to read why the run failed. Check ``eso_path is None``
                to test for the file without raising.
        """
        cached = object.__getattribute__(self, "_cached_eso")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        path = await self._async_find_output_file(".eso")
        if path is None:
            raise await self._async_missing_output("eso")
        result = await self._load_eso_async(path)
        object.__setattr__(self, "_cached_eso", result)
        return result

    async def async_mtr(self) -> ESOResult:
        """Parsed MTR meter time-series output (async, lazily cached).

        Non-blocking counterpart to [mtr][idfkit.simulation.result.SimulationResult.mtr] that uses
        [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

        Returns:
            An ESOResult for extracting meter time series.

        Raises:
            OutputNotFoundError: If the run produced no .mtr file. The message names the output
                object to add, or how to read why the run failed. Check ``mtr_path is None``
                to test for the file without raising.
        """
        cached = object.__getattribute__(self, "_cached_mtr")
        if cached is not _UNSET:
            return cached  # type: ignore[no-any-return]
        path = await self._async_find_output_file(".mtr")
        if path is None:
            raise await self._async_missing_output("mtr")
        result = await self._load_eso_async(path)
        object.__setattr__(self, "_cached_mtr", result)
        return result

    async def _async_find_output_file(self, suffix: str, *, table: bool = False) -> Path | None:
        """Async counterpart to [_find_output_file][].

        Uses [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for non-blocking file lookups, falling back
        to [fs][] or local path checks. The names tried, and the fallback, are
        those of the sync lookup.

        Args:
            suffix: File suffix to look for (e.g. ".sql", ".err").
            table: Look for the tabular report rather than a main output.

        Returns:
            Path to the file, or None if not found.
        """
        if self.refusal is not None or self.run_dir == REFUSED_RUN_DIR:
            return None

        if self.async_fs is not None:
            async_fs = self.async_fs
            for name in _output_names(self.output_prefix, suffix, table=table, style=self.output_suffix):
                candidate = self.run_dir / name
                if await async_fs.exists(str(candidate)):
                    return candidate
            matches = await async_fs.glob(str(self.run_dir), f"*{suffix}")
            return _pick_fallback(matches, suffix, table=table)

        return self._find_output_file(suffix, table=table)

    @classmethod
    def from_directory(
        cls,
        path: str | Path,
        *,
        output_prefix: str = "eplus",
        output_suffix: Literal["C", "L", "D"] | None = None,
        fs: FileSystem | None = None,
        async_fs: AsyncFileSystem | None = None,
    ) -> SimulationResult:
        """Reconstruct a SimulationResult from an existing output directory.

        Useful for inspecting results from a previous simulation run.

        Args:
            path: Path to the simulation output directory.
            output_prefix: Output file prefix used during the run.
            output_suffix: The run's ``--output-suffix`` style, if known; its
                file names are looked up first.
            fs: Optional sync file system backend for reading output files.
            async_fs: Optional async file system backend for non-blocking reads.

        Returns:
            SimulationResult pointing to the existing output.
        """
        run_dir = Path(path) if (fs is not None or async_fs is not None) else Path(path).resolve()
        return cls(
            run_dir=run_dir,
            success=True,
            exit_code=0,
            stdout="",
            stderr="",
            runtime_seconds=0.0,
            output_prefix=output_prefix,
            fs=fs,
            async_fs=async_fs,
            output_suffix=output_suffix,
        )

async_fs = field(default=None, repr=False) class-attribute instance-attribute

cached = False class-attribute instance-attribute

cancelled = False class-attribute instance-attribute

csv property

Parsed CSV output (lazily cached).

Returns:

Type Description
CSVResult

A CSVResult with extracted column metadata and values.

Raises:

Type Description
OutputNotFoundError

If the run produced no .csv file. The message names the output object to add, or how to read why the run failed. Check csv_path is None to test for the file without raising.

csv_path property

Path to the .csv output file, if present.

err_path property

Path to the .err output file, if present.

errors property

Parsed error report from the .err file (lazily cached).

Returns:

Type Description
ErrorReport

Parsed ErrorReport from the simulation's .err output.

eso property

Parsed ESO time-series output (lazily cached).

Returns:

Type Description
ESOResult

An ESOResult for extracting variable time series.

Raises:

Type Description
OutputNotFoundError

If the run produced no .eso file. The message names the output object to add, or how to read why the run failed. Check eso_path is None to test for the file without raising.

eso_path property

Path to the .eso output file, if present.

exit_code instance-attribute

fs = field(default=None, repr=False) class-attribute instance-attribute

html property

Parsed HTML tabular output (lazily cached).

Returns:

Type Description
HTMLResult

An HTMLResult with extracted tables and titles.

Raises:

Type Description
OutputNotFoundError

If the run produced no HTML table report. The message names the output object to add, or how to read why the run failed. Check html_path is None to test for the file without raising.

html_path property

Path to the HTML tabular output file, if present.

mdd_path property

Path to the .mdd output file, if present.

migration_report = field(default=None, repr=False) class-attribute instance-attribute

mtr property

Parsed MTR meter time-series output (lazily cached).

The .mtr meter file uses the same format as .eso, so it is parsed by the same reader.

Returns:

Type Description
ESOResult

An ESOResult for extracting meter time series.

Raises:

Type Description
OutputNotFoundError

If the run produced no .mtr file. The message names the output object to add, or how to read why the run failed. Check mtr_path is None to test for the file without raising.

mtr_path property

Path to the .mtr meter output file, if present.

output_prefix = 'eplus' class-attribute instance-attribute

output_suffix = field(default=None, repr=False) class-attribute instance-attribute

owns_run_dir = field(default=False, repr=False) class-attribute instance-attribute

rdd_path property

Path to the .rdd output file, if present.

refusal = None class-attribute instance-attribute

run_dir instance-attribute

runtime_seconds instance-attribute

sql property

Parsed SQL output database (lazily cached).

Returns:

Type Description
SQLResult

An SQLResult for querying time-series and tabular data.

Raises:

Type Description
OutputNotFoundError

If the run produced no .sql file. The message names the output object to add, or how to read why the run failed. Check sql_path is None to test for the file without raising.

sql_path property

Path to the SQLite output file, if present.

stderr = field(repr=False) class-attribute instance-attribute

stdout = field(repr=False) class-attribute instance-attribute

success instance-attribute

variables property

Output variable/meter index from .rdd/.mdd files (lazily cached).

Returns:

Type Description
OutputVariableIndex

An OutputVariableIndex for searching and injecting output

OutputVariableIndex

variables.

Raises:

Type Description
OutputNotFoundError

If the run produced no .rdd file. The message names the output object to add, or how to read why the run failed. Check rdd_path is None to test for the file without raising.

async_cleanup() async

Close open handles and delete run_dir if idfkit created it (async).

Non-blocking counterpart to cleanup: the delete runs in a worker thread. async with calls this on exit.

Source code in idfkit/simulation/result.py
async def async_cleanup(self) -> None:
    """Close open handles and delete ``run_dir`` if idfkit created it (async).

    Non-blocking counterpart to
    [cleanup][idfkit.simulation.result.SimulationResult.cleanup]: the delete
    runs in a worker thread. ``async with`` calls this on exit.
    """
    # Close on the calling thread: sqlite3 refuses to close a connection from a
    # thread other than the one that opened it, which would leave the file locked.
    self.close()
    if self.owns_run_dir:
        await asyncio.to_thread(self._remove_run_dir)

async_csv() async

Parsed CSV output (async, lazily cached).

Non-blocking counterpart to csv that uses async_fs for file reads.

Returns:

Type Description
CSVResult

A CSVResult with extracted column metadata and values.

Raises:

Type Description
OutputNotFoundError

If the run produced no .csv file. The message names the output object to add, or how to read why the run failed. Check csv_path is None to test for the file without raising.

Source code in idfkit/simulation/result.py
async def async_csv(self) -> CSVResult:
    """Parsed CSV output (async, lazily cached).

    Non-blocking counterpart to [csv][idfkit.simulation.result.SimulationResult.csv] that uses
    [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

    Returns:
        A CSVResult with extracted column metadata and values.

    Raises:
        OutputNotFoundError: If the run produced no .csv file. The message names the output
            object to add, or how to read why the run failed. Check ``csv_path is None``
            to test for the file without raising.
    """
    cached = object.__getattribute__(self, "_cached_csv")
    if cached is not _UNSET:
        return cached  # type: ignore[no-any-return]
    path = await self._async_find_output_file(".csv")
    if path is None:
        raise await self._async_missing_output("csv")
    from .parsers.csv import CSVResult as _CSVResult

    if self.async_fs is not None:
        text = await self.async_fs.read_text(str(path), encoding="latin-1")
        result: CSVResult = _CSVResult.from_string(text)
    elif self.fs is not None:
        text = self.fs.read_text(str(path), encoding="latin-1")
        result = _CSVResult.from_string(text)
    else:
        result = _CSVResult.from_file(path)
    object.__setattr__(self, "_cached_csv", result)
    return result

async_errors() async

Parsed error report from the .err file (async, lazily cached).

Non-blocking counterpart to errors that uses async_fs for file reads.

Returns:

Type Description
ErrorReport

Parsed ErrorReport from the simulation's .err output.

Source code in idfkit/simulation/result.py
async def async_errors(self) -> ErrorReport:
    """Parsed error report from the .err file (async, lazily cached).

    Non-blocking counterpart to [errors][idfkit.simulation.result.SimulationResult.errors] that uses
    [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

    Returns:
        Parsed ErrorReport from the simulation's .err output.
    """
    cached = object.__getattribute__(self, "_cached_errors")
    if cached is not _UNSET:
        return cached  # type: ignore[no-any-return]
    err = await self._async_find_output_file(".err")
    if self.refusal is not None:
        report = _refusal_report(self.refusal, cancelled=self.cancelled)
    elif err is None:
        report = ErrorReport.from_string("")
    elif self.async_fs is not None:
        text = await self.async_fs.read_text(str(err), encoding="latin-1")
        report = ErrorReport.from_string(text)
    elif self.fs is not None:
        text = self.fs.read_text(str(err), encoding="latin-1")
        report = ErrorReport.from_string(text)
    else:
        report = ErrorReport.from_file(err)
    object.__setattr__(self, "_cached_errors", report)
    return report

async_eso() async

Parsed ESO time-series output (async, lazily cached).

Non-blocking counterpart to eso that uses async_fs for file reads.

Returns:

Type Description
ESOResult

An ESOResult for extracting variable time series.

Raises:

Type Description
OutputNotFoundError

If the run produced no .eso file. The message names the output object to add, or how to read why the run failed. Check eso_path is None to test for the file without raising.

Source code in idfkit/simulation/result.py
async def async_eso(self) -> ESOResult:
    """Parsed ESO time-series output (async, lazily cached).

    Non-blocking counterpart to [eso][idfkit.simulation.result.SimulationResult.eso] that uses
    [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

    Returns:
        An ESOResult for extracting variable time series.

    Raises:
        OutputNotFoundError: If the run produced no .eso file. The message names the output
            object to add, or how to read why the run failed. Check ``eso_path is None``
            to test for the file without raising.
    """
    cached = object.__getattribute__(self, "_cached_eso")
    if cached is not _UNSET:
        return cached  # type: ignore[no-any-return]
    path = await self._async_find_output_file(".eso")
    if path is None:
        raise await self._async_missing_output("eso")
    result = await self._load_eso_async(path)
    object.__setattr__(self, "_cached_eso", result)
    return result

async_html() async

Parsed HTML tabular output (async, lazily cached).

Non-blocking counterpart to html that uses async_fs for file reads.

Returns:

Type Description
HTMLResult

An HTMLResult with extracted tables and titles.

Raises:

Type Description
OutputNotFoundError

If the run produced no HTML table report. The message names the output object to add, or how to read why the run failed. Check html_path is None to test for the file without raising.

Source code in idfkit/simulation/result.py
async def async_html(self) -> HTMLResult:
    """Parsed HTML tabular output (async, lazily cached).

    Non-blocking counterpart to [html][idfkit.simulation.result.SimulationResult.html] that uses
    [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

    Returns:
        An HTMLResult with extracted tables and titles.

    Raises:
        OutputNotFoundError: If the run produced no HTML table report. The message names the output
            object to add, or how to read why the run failed. Check ``html_path is None``
            to test for the file without raising.
    """
    cached = object.__getattribute__(self, "_cached_html")
    if cached is not _UNSET:
        return cached  # type: ignore[no-any-return]
    path = await self._async_find_output_file(".htm", table=True) or await self._async_find_output_file(
        ".html", table=True
    )
    if path is None:
        raise await self._async_missing_output("html")
    from .parsers.html import HTMLResult as _HTMLResult

    if self.async_fs is not None:
        text = await self.async_fs.read_text(str(path), encoding="latin-1")
        result: HTMLResult = _HTMLResult.from_string(text)
    elif self.fs is not None:
        text = self.fs.read_text(str(path), encoding="latin-1")
        result = _HTMLResult.from_string(text)
    else:
        result = _HTMLResult.from_file(path)
    object.__setattr__(self, "_cached_html", result)
    return result

async_mtr() async

Parsed MTR meter time-series output (async, lazily cached).

Non-blocking counterpart to mtr that uses async_fs for file reads.

Returns:

Type Description
ESOResult

An ESOResult for extracting meter time series.

Raises:

Type Description
OutputNotFoundError

If the run produced no .mtr file. The message names the output object to add, or how to read why the run failed. Check mtr_path is None to test for the file without raising.

Source code in idfkit/simulation/result.py
async def async_mtr(self) -> ESOResult:
    """Parsed MTR meter time-series output (async, lazily cached).

    Non-blocking counterpart to [mtr][idfkit.simulation.result.SimulationResult.mtr] that uses
    [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

    Returns:
        An ESOResult for extracting meter time series.

    Raises:
        OutputNotFoundError: If the run produced no .mtr file. The message names the output
            object to add, or how to read why the run failed. Check ``mtr_path is None``
            to test for the file without raising.
    """
    cached = object.__getattribute__(self, "_cached_mtr")
    if cached is not _UNSET:
        return cached  # type: ignore[no-any-return]
    path = await self._async_find_output_file(".mtr")
    if path is None:
        raise await self._async_missing_output("mtr")
    result = await self._load_eso_async(path)
    object.__setattr__(self, "_cached_mtr", result)
    return result

async_raise_for_status() async

Raise if the run failed; return this result if it succeeded (async).

Non-blocking counterpart to raise_for_status.

Raises:

Type Description
SimulationError

If the run failed.

Source code in idfkit/simulation/result.py
async def async_raise_for_status(self) -> SimulationResult:
    """Raise if the run failed; return this result if it succeeded (async).

    Non-blocking counterpart to [raise_for_status][idfkit.simulation.result.SimulationResult.raise_for_status].

    Raises:
        SimulationError: If the run failed.
    """
    if self.success:
        return self
    report = await self.async_errors()
    raise self._failure(report, await self._async_find_output_file(".err"))

async_sql() async

Parsed SQL output database (async, lazily cached).

Non-blocking counterpart to sql that uses async_fs for file reads.

Returns:

Type Description
SQLResult

An SQLResult for querying time-series and tabular data.

Raises:

Type Description
OutputNotFoundError

If the run produced no .sql file. The message names the output object to add, or how to read why the run failed. Check sql_path is None to test for the file without raising.

Source code in idfkit/simulation/result.py
async def async_sql(self) -> SQLResult:
    """Parsed SQL output database (async, lazily cached).

    Non-blocking counterpart to [sql][idfkit.simulation.result.SimulationResult.sql] that uses
    [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

    Returns:
        An SQLResult for querying time-series and tabular data.

    Raises:
        OutputNotFoundError: If the run produced no .sql file. The message names the output
            object to add, or how to read why the run failed. Check ``sql_path is None``
            to test for the file without raising.
    """
    cached = object.__getattribute__(self, "_cached_sql")
    if cached is not _UNSET:
        return cached  # type: ignore[no-any-return]
    path = await self._async_find_output_file(".sql")
    if path is None:
        raise await self._async_missing_output("sql")
    from .parsers.sql import SQLResult as _SQLResult

    if self.async_fs is not None:
        data = await self.async_fs.read_bytes(str(path))
        with tempfile.NamedTemporaryFile(suffix=".sql", delete=False) as tmp_file:
            tmp_file.write(data)
        result: SQLResult = _SQLResult(Path(tmp_file.name), _owns_file=True)
    elif self.fs is not None:
        data = self.fs.read_bytes(str(path))
        with tempfile.NamedTemporaryFile(suffix=".sql", delete=False) as tmp_file:
            tmp_file.write(data)
        result = _SQLResult(Path(tmp_file.name), _owns_file=True)
    else:
        result = _SQLResult(path)
    object.__setattr__(self, "_cached_sql", result)
    return result

async_variables() async

Output variable/meter index (async, lazily cached).

Non-blocking counterpart to variables that uses async_fs for file reads.

Returns:

Type Description
OutputVariableIndex

An OutputVariableIndex for searching and injecting output

OutputVariableIndex

variables.

Raises:

Type Description
OutputNotFoundError

If the run produced no .rdd file. The message names the output object to add, or how to read why the run failed. Check rdd_path is None to test for the file without raising.

Source code in idfkit/simulation/result.py
async def async_variables(self) -> OutputVariableIndex:
    """Output variable/meter index (async, lazily cached).

    Non-blocking counterpart to [variables][idfkit.simulation.result.SimulationResult.variables] that uses
    [async_fs][idfkit.simulation.result.SimulationResult.async_fs] for file reads.

    Returns:
        An OutputVariableIndex for searching and injecting output
        variables.

    Raises:
        OutputNotFoundError: If the run produced no .rdd file. The message names the output
            object to add, or how to read why the run failed. Check ``rdd_path is None``
            to test for the file without raising.
    """
    cached = object.__getattribute__(self, "_cached_variables")
    if cached is not _UNSET:
        return cached  # type: ignore[no-any-return]
    rdd = await self._async_find_output_file(".rdd")
    if rdd is None:
        raise await self._async_missing_output("variables")

    if self.async_fs is not None:
        from .parsers.rdd import parse_mdd, parse_rdd

        rdd_text = await self.async_fs.read_text(str(rdd), encoding="latin-1")
        variables = parse_rdd(rdd_text)
        mdd = await self._async_find_output_file(".mdd")
        meters = parse_mdd(await self.async_fs.read_text(str(mdd), encoding="latin-1")) if mdd is not None else ()
        from .outputs import OutputVariableIndex as _OutputVariableIndex

        result: OutputVariableIndex = _OutputVariableIndex(variables=variables, meters=meters)
    elif self.fs is not None:
        from .parsers.rdd import parse_mdd, parse_rdd

        rdd_text = self.fs.read_text(str(rdd), encoding="latin-1")
        variables = parse_rdd(rdd_text)
        mdd = self._find_output_file(".mdd")
        meters = parse_mdd(self.fs.read_text(str(mdd), encoding="latin-1")) if mdd is not None else ()
        from .outputs import OutputVariableIndex as _OutputVariableIndex

        result = _OutputVariableIndex(variables=variables, meters=meters)
    else:
        from .outputs import OutputVariableIndex as _OutputVariableIndex

        result = _OutputVariableIndex.from_files(rdd, self.mdd_path)
    object.__setattr__(self, "_cached_variables", result)
    return result

cleanup()

Close open handles and delete run_dir if idfkit created it.

simulate() without an output_dir runs EnergyPlus in a new temporary directory, which nothing deletes on its own because the output accessors read their files from it lazily. This deletes it once you are done with the result. A caller-supplied output_dir, a remote fs directory and a cache entry are never touched (owns_run_dir is False for them): for those this only calls close.

The SQLite connection is closed first, so the delete is not blocked by a file lock on Windows. Read what you need before calling it: an output not parsed before the delete can no longer be read. Safe to call more than once.

Using the result as a context manager calls this on exit::

with simulate(model, "weather.epw") as result:
    print(result.errors.summary())
# the temporary run directory is gone here

Raises:

Type Description
OSError

If the directory exists and cannot be deleted.

Source code in idfkit/simulation/result.py
def cleanup(self) -> None:
    """Close open handles and delete ``run_dir`` if idfkit created it.

    ``simulate()`` without an ``output_dir`` runs EnergyPlus in a new
    temporary directory, which nothing deletes on its own because the
    output accessors read their files from it lazily. This deletes it once
    you are done with the result. A caller-supplied ``output_dir``, a remote
    ``fs`` directory and a cache entry are never touched
    ([owns_run_dir][idfkit.simulation.result.SimulationResult.owns_run_dir]
    is ``False`` for them): for those this only calls
    [close][idfkit.simulation.result.SimulationResult.close].

    The SQLite connection is closed first, so the delete is not blocked by
    a file lock on Windows. Read what you need before calling it: an output
    not parsed before the delete can no longer be read. Safe to call more
    than once.

    Using the result as a context manager calls this on exit::

        with simulate(model, "weather.epw") as result:
            print(result.errors.summary())
        # the temporary run directory is gone here

    Raises:
        OSError: If the directory exists and cannot be deleted.
    """
    self.close()
    if self.owns_run_dir:
        self._remove_run_dir()

close()

Release any open file handles held by cached parsers.

Closes the SQLite connection opened lazily by sql / async_sql (and removes the temporary copy made for remote file systems). The other parsers read their files eagerly and hold no handles, so this is currently a no-op for them.

Call this before deleting the run directory yourself. On Windows an open SQLite connection locks eplus.sql and blocks shutil.rmtree / TemporaryDirectory cleanup with PermissionError [WinError 32]. Safe to call more than once; the cached connection is reopened on next access if needed. Leaves run_dir in place; see cleanup to delete it.

Source code in idfkit/simulation/result.py
def close(self) -> None:
    """Release any open file handles held by cached parsers.

    Closes the SQLite connection opened lazily by [sql][idfkit.simulation.result.SimulationResult.sql] /
    [async_sql][idfkit.simulation.result.SimulationResult.async_sql] (and removes the temporary copy made
    for remote file systems). The other parsers read their files eagerly
    and hold no handles, so this is currently a no-op for them.

    Call this before deleting the run directory yourself. On Windows an
    open SQLite connection locks ``eplus.sql`` and blocks ``shutil.rmtree``
    / ``TemporaryDirectory`` cleanup with ``PermissionError [WinError 32]``.
    Safe to call more than once; the cached connection is reopened on next
    access if needed. Leaves ``run_dir`` in place; see
    [cleanup][idfkit.simulation.result.SimulationResult.cleanup] to delete it.
    """
    cached = object.__getattribute__(self, "_cached_sql")
    if cached is not _UNSET:
        cached.close()
    object.__setattr__(self, "_cached_sql", _UNSET)

from_directory(path, *, output_prefix='eplus', output_suffix=None, fs=None, async_fs=None) classmethod

Reconstruct a SimulationResult from an existing output directory.

Useful for inspecting results from a previous simulation run.

Parameters:

Name Type Description Default
path str | Path

Path to the simulation output directory.

required
output_prefix str

Output file prefix used during the run.

'eplus'
output_suffix Literal['C', 'L', 'D'] | None

The run's --output-suffix style, if known; its file names are looked up first.

None
fs FileSystem | None

Optional sync file system backend for reading output files.

None
async_fs AsyncFileSystem | None

Optional async file system backend for non-blocking reads.

None

Returns:

Type Description
SimulationResult

SimulationResult pointing to the existing output.

Source code in idfkit/simulation/result.py
@classmethod
def from_directory(
    cls,
    path: str | Path,
    *,
    output_prefix: str = "eplus",
    output_suffix: Literal["C", "L", "D"] | None = None,
    fs: FileSystem | None = None,
    async_fs: AsyncFileSystem | None = None,
) -> SimulationResult:
    """Reconstruct a SimulationResult from an existing output directory.

    Useful for inspecting results from a previous simulation run.

    Args:
        path: Path to the simulation output directory.
        output_prefix: Output file prefix used during the run.
        output_suffix: The run's ``--output-suffix`` style, if known; its
            file names are looked up first.
        fs: Optional sync file system backend for reading output files.
        async_fs: Optional async file system backend for non-blocking reads.

    Returns:
        SimulationResult pointing to the existing output.
    """
    run_dir = Path(path) if (fs is not None or async_fs is not None) else Path(path).resolve()
    return cls(
        run_dir=run_dir,
        success=True,
        exit_code=0,
        stdout="",
        stderr="",
        runtime_seconds=0.0,
        output_prefix=output_prefix,
        fs=fs,
        async_fs=async_fs,
        output_suffix=output_suffix,
    )

raise_for_status()

Raise if the run failed; return this result if it succeeded.

simulate() reports a failed run in the result rather than raising, so a caller that wants to stop on failure calls this: result = simulate(doc, epw).raise_for_status().

Returns:

Type Description
SimulationResult

This result, when success is true.

Raises:

Type Description
SimulationError

If the run failed. Its message names the .err file and quotes the fatal and first severe errors; its result is this result.

RuntimeError

If the result reads its files through an AsyncFileSystem; use async_raise_for_status.

Source code in idfkit/simulation/result.py
def raise_for_status(self) -> SimulationResult:
    """Raise if the run failed; return this result if it succeeded.

    ``simulate()`` reports a failed run in the result rather than raising, so a caller that
    wants to stop on failure calls this: ``result = simulate(doc, epw).raise_for_status()``.

    Returns:
        This result, when [success][idfkit.simulation.result.SimulationResult.success] is true.

    Raises:
        SimulationError: If the run failed. Its message names the ``.err`` file and quotes the
            fatal and first severe errors; its ``result`` is this result.
        RuntimeError: If the result reads its files through an ``AsyncFileSystem``; use
            [async_raise_for_status][idfkit.simulation.result.SimulationResult.async_raise_for_status].
    """
    if self.success:
        return self
    raise self._failure(self.errors, self.err_path)

ErrorReport

idfkit.simulation.parsers.err.ErrorReport dataclass

Parsed contents of an EnergyPlus .err file.

Attributes:

Name Type Description
fatal tuple[ErrorMessage, ...]

Fatal error messages.

severe tuple[ErrorMessage, ...]

Severe error messages.

warnings tuple[ErrorMessage, ...]

Warning messages.

info tuple[ErrorMessage, ...]

Informational messages.

warmup_converged bool

Whether warmup convergence was reported.

simulation_complete bool

Whether the simulation completed successfully.

raw_text str

The original unparsed file text.

Source code in idfkit/simulation/parsers/err.py
@dataclass(frozen=True, slots=True)
class ErrorReport:
    """Parsed contents of an EnergyPlus .err file.

    Attributes:
        fatal: Fatal error messages.
        severe: Severe error messages.
        warnings: Warning messages.
        info: Informational messages.
        warmup_converged: Whether warmup convergence was reported.
        simulation_complete: Whether the simulation completed successfully.
        raw_text: The original unparsed file text.
    """

    fatal: tuple[ErrorMessage, ...]
    severe: tuple[ErrorMessage, ...]
    warnings: tuple[ErrorMessage, ...]
    info: tuple[ErrorMessage, ...]
    warmup_converged: bool
    simulation_complete: bool
    raw_text: str

    @property
    def has_fatal(self) -> bool:
        """Whether any fatal errors were found."""
        return len(self.fatal) > 0

    @property
    def has_severe(self) -> bool:
        """Whether any severe errors were found."""
        return len(self.severe) > 0

    @property
    def fatal_count(self) -> int:
        """Number of fatal errors."""
        return len(self.fatal)

    @property
    def severe_count(self) -> int:
        """Number of severe errors."""
        return len(self.severe)

    @property
    def error_count(self) -> int:
        """Total number of fatal + severe errors."""
        return len(self.fatal) + len(self.severe)

    @property
    def warning_count(self) -> int:
        """Total number of warnings."""
        return len(self.warnings)

    def summary(self, max_messages: int = 3) -> str:
        """Return a human-readable summary of the error report.

        The counts and the run's outcome, then the fatal errors and the first severe ones, with
        their continuation lines, so the cause of a failed run reads at a glance.

        Args:
            max_messages: How many severe errors to quote; the fatal ones are always quoted.
                ``0`` quotes none.

        Returns:
            A multi-line summary string.
        """
        lines: list[str] = []
        lines.append(
            f"Fatal: {len(self.fatal)}, Severe: {len(self.severe)}, "
            f"Warnings: {len(self.warnings)}, Info: {len(self.info)}"
        )
        if self.warmup_converged:
            lines.append("Warmup: converged")
        if self.simulation_complete:
            lines.append("Simulation: completed successfully")
        elif self.has_fatal:
            lines.append("Simulation: terminated with fatal error(s)")
        quoted = (*self.fatal, *self.severe[: max(max_messages, 0)])
        for msg in quoted:
            lines.append(f"  {msg.severity}: {msg.message}")
            lines.extend(f"    {detail}" for detail in msg.details)
        unquoted = len(self.severe) - (len(quoted) - len(self.fatal))
        if unquoted:
            lines.append(f"  ... and {unquoted} more severe error(s)")
        return "\n".join(lines)

    @classmethod
    def from_file(cls, path: str | Path) -> ErrorReport:
        """Parse an .err file from disk.

        Args:
            path: Path to the .err file.

        Returns:
            Parsed ErrorReport.
        """
        text = Path(path).read_text(encoding="latin-1")
        return _parse_err(text)

    @classmethod
    def from_string(cls, text: str) -> ErrorReport:
        """Parse .err content from a string.

        Args:
            text: Raw .err file contents.

        Returns:
            Parsed ErrorReport.
        """
        return _parse_err(text)

error_count property

Total number of fatal + severe errors.

fatal instance-attribute

fatal_count property

Number of fatal errors.

has_fatal property

Whether any fatal errors were found.

has_severe property

Whether any severe errors were found.

info instance-attribute

raw_text instance-attribute

severe instance-attribute

severe_count property

Number of severe errors.

simulation_complete instance-attribute

warmup_converged instance-attribute

warning_count property

Total number of warnings.

warnings instance-attribute

from_file(path) classmethod

Parse an .err file from disk.

Parameters:

Name Type Description Default
path str | Path

Path to the .err file.

required

Returns:

Type Description
ErrorReport

Parsed ErrorReport.

Source code in idfkit/simulation/parsers/err.py
@classmethod
def from_file(cls, path: str | Path) -> ErrorReport:
    """Parse an .err file from disk.

    Args:
        path: Path to the .err file.

    Returns:
        Parsed ErrorReport.
    """
    text = Path(path).read_text(encoding="latin-1")
    return _parse_err(text)

from_string(text) classmethod

Parse .err content from a string.

Parameters:

Name Type Description Default
text str

Raw .err file contents.

required

Returns:

Type Description
ErrorReport

Parsed ErrorReport.

Source code in idfkit/simulation/parsers/err.py
@classmethod
def from_string(cls, text: str) -> ErrorReport:
    """Parse .err content from a string.

    Args:
        text: Raw .err file contents.

    Returns:
        Parsed ErrorReport.
    """
    return _parse_err(text)

summary(max_messages=3)

Return a human-readable summary of the error report.

The counts and the run's outcome, then the fatal errors and the first severe ones, with their continuation lines, so the cause of a failed run reads at a glance.

Parameters:

Name Type Description Default
max_messages int

How many severe errors to quote; the fatal ones are always quoted. 0 quotes none.

3

Returns:

Type Description
str

A multi-line summary string.

Source code in idfkit/simulation/parsers/err.py
def summary(self, max_messages: int = 3) -> str:
    """Return a human-readable summary of the error report.

    The counts and the run's outcome, then the fatal errors and the first severe ones, with
    their continuation lines, so the cause of a failed run reads at a glance.

    Args:
        max_messages: How many severe errors to quote; the fatal ones are always quoted.
            ``0`` quotes none.

    Returns:
        A multi-line summary string.
    """
    lines: list[str] = []
    lines.append(
        f"Fatal: {len(self.fatal)}, Severe: {len(self.severe)}, "
        f"Warnings: {len(self.warnings)}, Info: {len(self.info)}"
    )
    if self.warmup_converged:
        lines.append("Warmup: converged")
    if self.simulation_complete:
        lines.append("Simulation: completed successfully")
    elif self.has_fatal:
        lines.append("Simulation: terminated with fatal error(s)")
    quoted = (*self.fatal, *self.severe[: max(max_messages, 0)])
    for msg in quoted:
        lines.append(f"  {msg.severity}: {msg.message}")
        lines.extend(f"    {detail}" for detail in msg.details)
    unquoted = len(self.severe) - (len(quoted) - len(self.fatal))
    if unquoted:
        lines.append(f"  ... and {unquoted} more severe error(s)")
    return "\n".join(lines)

ErrorMessage

idfkit.simulation.parsers.err.ErrorMessage dataclass

A single error/warning message from EnergyPlus.

Attributes:

Name Type Description
severity str

One of "Fatal", "Severe", "Warning", "Info".

message str

The primary message text.

details tuple[str, ...]

Additional continuation lines (** ~~~ ** lines).

Source code in idfkit/simulation/parsers/err.py
@dataclass(frozen=True, slots=True)
class ErrorMessage:
    """A single error/warning message from EnergyPlus.

    Attributes:
        severity: One of "Fatal", "Severe", "Warning", "Info".
        message: The primary message text.
        details: Additional continuation lines (``** ~~~   **`` lines).
    """

    severity: str
    message: str
    details: tuple[str, ...]

details instance-attribute

message instance-attribute

severity instance-attribute

HTMLResult

idfkit.simulation.parsers.html.HTMLResult dataclass

Parsed HTML tabular output from an EnergyPlus simulation.

Attributes:

Name Type Description
tables list[HTMLTable]

All tables extracted from the file, in document order.

Source code in idfkit/simulation/parsers/html.py
@dataclass(slots=True)
class HTMLResult:
    """Parsed HTML tabular output from an EnergyPlus simulation.

    Attributes:
        tables: All tables extracted from the file, in document order.
    """

    tables: list[HTMLTable] = field(default_factory=lambda: [])

    @classmethod
    def from_file(cls, path: Path | str, encoding: str = "latin-1") -> HTMLResult:
        """Parse an EnergyPlus HTML output file.

        Args:
            path: Path to the HTML file (typically ``eplustblTable.html``
                or ``eplusoutTable.html``).
            encoding: File encoding (default ``latin-1``).

        Returns:
            Parsed [HTMLResult][idfkit.simulation.parsers.html.HTMLResult].
        """
        with open(path, encoding=encoding, errors="replace") as f:
            return cls.from_string(f.read())

    @classmethod
    def from_string(cls, html: str) -> HTMLResult:
        """Parse an HTML string.

        Args:
            html: The raw HTML content.

        Returns:
            Parsed [HTMLResult][idfkit.simulation.parsers.html.HTMLResult].
        """
        parser = _EnergyPlusHTMLParser()
        parser.feed(html)
        return cls(tables=parser.tables)

    def __len__(self) -> int:
        return len(self.tables)

    def __getitem__(self, index: int) -> HTMLTable:
        return self.tables[index]

    def __iter__(self) -> Iterator[HTMLTable]:
        return iter(self.tables)

    # ------------------------------------------------------------------
    # Convenience accessors (eppy-compatible patterns)
    # ------------------------------------------------------------------

    def titletable(self) -> list[tuple[str, list[list[str]]]]:
        """Return ``(title, rows)`` pairs like eppy's ``readhtml.titletable``.

        Each entry is ``(bold_title, [header_row, *data_rows])``.
        """
        result: list[tuple[str, list[list[str]]]] = []
        for t in self.tables:
            combined = [t.header, *t.rows] if t.header else list(t.rows)
            result.append((t.title, combined))
        return result

    def tablebyname(self, name: str) -> HTMLTable | None:
        """Find first table whose title contains *name* (case-insensitive)."""
        lower = name.lower()
        for t in self.tables:
            if lower in t.title.lower():
                return t
        return None

    def tablebyindex(self, index: int) -> HTMLTable | None:
        """Get a table by its zero-based position."""
        if 0 <= index < len(self.tables):
            return self.tables[index]
        return None

    def tablesbyreport(self, report_name: str) -> list[HTMLTable]:
        """Get all tables belonging to a specific report."""
        lower = report_name.lower()
        return [t for t in self.tables if lower in t.report_name.lower()]

tables = field(default_factory=lambda: []) class-attribute instance-attribute

from_file(path, encoding='latin-1') classmethod

Parse an EnergyPlus HTML output file.

Parameters:

Name Type Description Default
path Path | str

Path to the HTML file (typically eplustblTable.html or eplusoutTable.html).

required
encoding str

File encoding (default latin-1).

'latin-1'

Returns:

Type Description
HTMLResult

Parsed HTMLResult.

Source code in idfkit/simulation/parsers/html.py
@classmethod
def from_file(cls, path: Path | str, encoding: str = "latin-1") -> HTMLResult:
    """Parse an EnergyPlus HTML output file.

    Args:
        path: Path to the HTML file (typically ``eplustblTable.html``
            or ``eplusoutTable.html``).
        encoding: File encoding (default ``latin-1``).

    Returns:
        Parsed [HTMLResult][idfkit.simulation.parsers.html.HTMLResult].
    """
    with open(path, encoding=encoding, errors="replace") as f:
        return cls.from_string(f.read())

from_string(html) classmethod

Parse an HTML string.

Parameters:

Name Type Description Default
html str

The raw HTML content.

required

Returns:

Type Description
HTMLResult

Parsed HTMLResult.

Source code in idfkit/simulation/parsers/html.py
@classmethod
def from_string(cls, html: str) -> HTMLResult:
    """Parse an HTML string.

    Args:
        html: The raw HTML content.

    Returns:
        Parsed [HTMLResult][idfkit.simulation.parsers.html.HTMLResult].
    """
    parser = _EnergyPlusHTMLParser()
    parser.feed(html)
    return cls(tables=parser.tables)

tablebyindex(index)

Get a table by its zero-based position.

Source code in idfkit/simulation/parsers/html.py
def tablebyindex(self, index: int) -> HTMLTable | None:
    """Get a table by its zero-based position."""
    if 0 <= index < len(self.tables):
        return self.tables[index]
    return None

tablebyname(name)

Find first table whose title contains name (case-insensitive).

Source code in idfkit/simulation/parsers/html.py
def tablebyname(self, name: str) -> HTMLTable | None:
    """Find first table whose title contains *name* (case-insensitive)."""
    lower = name.lower()
    for t in self.tables:
        if lower in t.title.lower():
            return t
    return None

tablesbyreport(report_name)

Get all tables belonging to a specific report.

Source code in idfkit/simulation/parsers/html.py
def tablesbyreport(self, report_name: str) -> list[HTMLTable]:
    """Get all tables belonging to a specific report."""
    lower = report_name.lower()
    return [t for t in self.tables if lower in t.report_name.lower()]

titletable()

Return (title, rows) pairs like eppy's readhtml.titletable.

Each entry is (bold_title, [header_row, *data_rows]).

Source code in idfkit/simulation/parsers/html.py
def titletable(self) -> list[tuple[str, list[list[str]]]]:
    """Return ``(title, rows)`` pairs like eppy's ``readhtml.titletable``.

    Each entry is ``(bold_title, [header_row, *data_rows])``.
    """
    result: list[tuple[str, list[list[str]]]] = []
    for t in self.tables:
        combined = [t.header, *t.rows] if t.header else list(t.rows)
        result.append((t.title, combined))
    return result

HTMLTable

idfkit.simulation.parsers.html.HTMLTable dataclass

A single table extracted from the EnergyPlus HTML output.

Attributes:

Name Type Description
title str

The bold title preceding the table (e.g. "Site and Source Energy").

header list[str]

Column headers: the first <tr> with <th> cells or, when the table has none (EnergyPlus writes its headers as <td>), the table's first row.

rows list[list[str]]

Data rows as lists of strings, without the header row.

report_name str

The top-level report name (e.g. "Annual Building Utility Performance Summary").

for_string str

The "For:" qualifier (e.g. "Entire Facility").

Source code in idfkit/simulation/parsers/html.py
@dataclass(slots=True)
class HTMLTable:
    """A single table extracted from the EnergyPlus HTML output.

    Attributes:
        title: The bold title preceding the table (e.g.
            ``"Site and Source Energy"``).
        header: Column headers: the first ``<tr>`` with ``<th>`` cells or,
            when the table has none (EnergyPlus writes its headers as
            ``<td>``), the table's first row.
        rows: Data rows as lists of strings, without the header row.
        report_name: The top-level report name (e.g.
            ``"Annual Building Utility Performance Summary"``).
        for_string: The ``"For:"`` qualifier (e.g. ``"Entire Facility"``).
    """

    title: str
    header: list[str]
    rows: list[list[str]]
    report_name: str = ""
    for_string: str = ""

    def to_dict(self) -> dict[str, dict[str, str]]:
        """Convert to a dict mapping row headers to {col_header: value}.

        The first column is treated as the row key.  Remaining columns
        are keyed by their respective column headers (starting at
        index 1).  Duplicate row keys are silently overwritten by the
        last occurrence.

        This gives convenient dict-style access similar to eppy's
        ``readhtml.named_grid_h``.
        """
        result: dict[str, dict[str, str]] = {}
        for row in self.rows:
            if not row:
                continue
            row_key = row[0]
            entry: dict[str, str] = {}
            for i in range(1, len(self.header)):
                if i < len(row):
                    entry[self.header[i]] = row[i]
            result[row_key] = entry
        return result

for_string = '' class-attribute instance-attribute

header instance-attribute

report_name = '' class-attribute instance-attribute

rows instance-attribute

title instance-attribute

to_dict()

Convert to a dict mapping row headers to {col_header: value}.

The first column is treated as the row key. Remaining columns are keyed by their respective column headers (starting at index 1). Duplicate row keys are silently overwritten by the last occurrence.

This gives convenient dict-style access similar to eppy's readhtml.named_grid_h.

Source code in idfkit/simulation/parsers/html.py
def to_dict(self) -> dict[str, dict[str, str]]:
    """Convert to a dict mapping row headers to {col_header: value}.

    The first column is treated as the row key.  Remaining columns
    are keyed by their respective column headers (starting at
    index 1).  Duplicate row keys are silently overwritten by the
    last occurrence.

    This gives convenient dict-style access similar to eppy's
    ``readhtml.named_grid_h``.
    """
    result: dict[str, dict[str, str]] = {}
    for row in self.rows:
        if not row:
            continue
        row_key = row[0]
        entry: dict[str, str] = {}
        for i in range(1, len(self.header)):
            if i < len(row):
                entry[self.header[i]] = row[i]
        result[row_key] = entry
    return result