From 92b055ded19270ab2ca966d3d32369e41b127ccf Mon Sep 17 00:00:00 2001 From: jamiebull1 <^tA2nq%K&F8TB&At> Date: Wed, 7 Aug 2019 11:43:25 +0200 Subject: [PATCH 1/2] Test that missed expandobjects flag leads to run failure --- eppy/tests/test_runner.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/eppy/tests/test_runner.py b/eppy/tests/test_runner.py index 0fd2e74b..89b5d6d9 100644 --- a/eppy/tests/test_runner.py +++ b/eppy/tests/test_runner.py @@ -368,6 +368,26 @@ def test_run_expandobjects(self, test_idf): self.expected_files.extend(["eplusout.expidf"]) assert set(files) == set(self.expected_files) + def test_run_expandobjects_no_flag(self, test_idf): + """ + End to end test of idf.run function with expandobjects flag unset. + Fails on severe errors or unexpected/missing output files. + + """ + test_idf.newidfobject( + "HVACTEMPLATE:THERMOSTAT", + Name="TestThermostat", + Cooling_Setpoint_Schedule_Name="", + Heating_Setpoint_Schedule_Name="", + Constant_Cooling_Setpoint=25, + Constant_Heating_Setpoint=21, + ) + test_idf.run(output_directory="run_outputs") + assert not has_severe_errors() + files = os.listdir("run_outputs") + self.expected_files.extend(["eplusout.expidf"]) + assert set(files) == set(self.expected_files) + def test_run_output_prefix(self, test_idf): """ End to end test of idf.run function with output prefix set. From cb70c435b64967b55e31e7b9d7d15fdcfe312607 Mon Sep 17 00:00:00 2001 From: jamiebull1 <^tA2nq%K&F8TB&At> Date: Wed, 7 Aug 2019 11:44:17 +0200 Subject: [PATCH 2/2] Add expandobjects flag if any HVACTemplate objects are present in IDF --- eppy/runner/run_functions.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/eppy/runner/run_functions.py b/eppy/runner/run_functions.py index 4dd038a7..0dc44e8d 100644 --- a/eppy/runner/run_functions.py +++ b/eppy/runner/run_functions.py @@ -297,6 +297,13 @@ def run( idf_path = os.path.abspath(idf.idfname) except AttributeError: idf_path = os.path.abspath(idf) + if not os.path.isfile(idf_path): + raise EnergyPlusRunError( + "ERROR: Could not find input data file: {}".format(idf_path) + ) + if not expandobjects: + with open(idf_path, "r") as f: + args["expandobjects"] = "HVACTEMPLATE:" in f.read().upper() ep_version = args.pop("ep_version") # get version from IDF object or by parsing the IDF file for it if not ep_version: