From e484b1bb331770d29afa550b3a74cfce9960c477 Mon Sep 17 00:00:00 2001 From: taoning Date: Wed, 6 Nov 2024 12:43:10 -0800 Subject: [PATCH] fix(eplus): not forcing tempfile cleanup for windows --- frads/eplus.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/frads/eplus.py b/frads/eplus.py index 4969686..5ea91d1 100644 --- a/frads/eplus.py +++ b/frads/eplus.py @@ -130,22 +130,22 @@ def _get_list_of_actuators(self): actuator_state, self._actuator_func ) - with tempfile.TemporaryDirectory() as tmpdir: - inp = os.path.join(tmpdir, "in.json") - with open(inp, "w") as wtr: - wtr.write(self.model.model_dump_json(by_alias=True, exclude_none=True)) + tmpdir = tempfile.mkdtemp() + inp = os.path.join(tmpdir, "in.json") + with open(inp, "w") as wtr: + wtr.write(self.model.model_dump_json(by_alias=True, exclude_none=True)) - if self.epw is not None: - self.api.runtime.run_energyplus( - actuator_state, ["-p", "actuator", "-d", tmpdir, "-w", self.epw, inp] - ) - elif self.model.sizing_period_design_day is not None: - self.api.runtime.run_energyplus(actuator_state, ["-D", "-d", tmpdir, inp]) - else: - raise ValueError( - "Specify weather file in EnergyPlusSetup " - "or model design day in EnergyPlusModel." - ) + if self.epw is not None: + self.api.runtime.run_energyplus( + actuator_state, ["-p", "actuator", "-d", tmpdir, "-w", self.epw, inp] + ) + elif self.model.sizing_period_design_day is not None: + self.api.runtime.run_energyplus(actuator_state, ["-D", "-d", tmpdir, inp]) + else: + raise ValueError( + "Specify weather file in EnergyPlusSetup " + "or model design day in EnergyPlusModel." + ) self.api.state_manager.delete_state(actuator_state) def actuate(self, component_type: str, name: str, key: str, value: float):