You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
KeyError when an .eso data line has an undeclared report ID #39
DBEsoFileCollection.from_path() raises a bare KeyError when a data line's report ID is not declared for the current frequency in the file's data dictionary. One such line is enough to stop the whole file loading.
Reproduce
Using main at 27f36ef, take any valid .eso file and insert one data line with an undeclared ID just before End of Data:
File "db_eplusout_reader/processing/esofile_reader.py", line 312, in read_body
raw_outputs.outputs[frequency][line_id][-1] = res
KeyError: 99999
I found this when comparing the reader with idfkit's ESO parser. idfkit's edge-case test (tests/test_simulation_eso_parser.py::test_unknown_report_id_is_skipped) uses exactly this input and skips the line. All 1,654 variable/environment series in the files I compared matched idfkit's values exactly, so this was the only real difference.
Cause
In read_body, a result line is written straight to raw_outputs.outputs[frequency][line_id]. There's no check that line_id was declared for the current frequency.
Suggested fix
Skip result lines whose ID has no output slot for the current frequency, and log them at debug level instead of failing the whole file. Add a test with an injected unknown ID, checking that every declared variable still reads correctly.
EnergyPlus shouldn't write such lines itself, so this is about robustness: hand-edited or post-processed files, or files joined from several runs.
Activity