Spaces:
Configuration error
Configuration error
Download pcswmm_ai/simulation.py from razaali10/PCSWMM-MCP-Server: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/razaali10/PCSWMM-MCP-Server/resolve/main/pcswmm_ai/simulation.py
- Command line
-
hf download hf://spaces/razaali10/PCSWMM-MCP-Server/pcswmm_ai/simulation.py
-
curl -L -o simulation.py https://huggingface.co/spaces/razaali10/PCSWMM-MCP-Server/resolve/main/pcswmm_ai/simulation.py
1.12 kB
| from __future__ import annotations | |
| from datetime import datetime | |
| from typing import Any | |
| from .project import ProjectService | |
| from .utils import safe_count, safe_text | |
| class SimulationService: | |
| def __init__(self, pcpy: Any, project: ProjectService): | |
| self._pcpy = pcpy | |
| self._project = project | |
| def run(self) -> dict[str, Any]: | |
| self._project.require_open() | |
| started = datetime.now() | |
| self._pcpy.SWMM.run() | |
| finished = datetime.now() | |
| try: | |
| graph_file_count = safe_count(self._pcpy.Graph.Files) | |
| except Exception: | |
| graph_file_count = 0 | |
| return { | |
| "status": "completed", | |
| "started_at": started.isoformat(timespec="seconds"), | |
| "finished_at": finished.isoformat(timespec="seconds"), | |
| "elapsed_seconds": round((finished - started).total_seconds(), 3), | |
| "run_status": safe_text(self._pcpy.SWMM.RunStatus), | |
| "graph_file_count": graph_file_count, | |
| } | |
| def refresh_output(self): | |
| self._project.require_open() | |
| self._pcpy.SWMM.refresh_output() | |