实现多进程 epanet 模拟,不保留临时文件

This commit is contained in:
2026-03-18 16:56:44 +08:00
parent c5d3075ae2
commit 7c44654195
6 changed files with 114 additions and 127 deletions
+6 -7
View File
@@ -9,7 +9,6 @@ from app.algorithms.simulation.runner import (
run_simulation_ex,
from_clock_to_seconds_2,
)
from app.infra.epanet.epanet import Output
from app.services.scheme_management import store_scheme_info
from app.services.tjnetwork import (
ChangeSet,
@@ -666,21 +665,21 @@ def age_analysis(
modify_total_duration,
downloading_prohibition=True,
)
simulation_result = json.loads(result)
output_data = simulation_result.get("output")
if not isinstance(output_data, dict):
raise RuntimeError("run_simulation_ex did not return JSON output content")
# step 2. restore the base model status
# execute_undo(name) #有疑惑
if is_project_open(new_name):
close_project(new_name)
delete_project(new_name)
output = Output("./temp/{}.db.out".format(new_name))
# element_name = output.element_name()
# node_name = element_name['nodes']
# link_name = element_name['links']
nodes_age = []
node_result = output.node_results()
node_result = output_data.get("node_results") or []
for node in node_result:
nodes_age.append(node["result"][-1]["quality"])
links_age = []
link_result = output.link_results()
link_result = output_data.get("link_results") or []
for link in link_result:
links_age.append(link["result"][-1]["quality"])
age_result = {"nodes": nodes_age, "links": links_age}