Coverage for backend/ahuora-builder/src/ahuora_builder/port_manager.py: 83%
12 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-03-26 20:57 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-03-26 20:57 +0000
1from pyomo.network import Port
2from ahuora_builder_types import PortId
5class PortManager:
7 def __init__(self) -> None:
8 self._map: dict[PortId, Port] = {}
11 def register_port(self, id: PortId, port: Port) -> None:
12 """Registers a port with the port map, so that arcs can connect to it by id"""
13 self._map[id] = port
16 def get_port(self, id: PortId) -> Port:
17 try:
18 return self._map[id]
19 except KeyError:
20 raise KeyError(f"Port with id `{id}` not found")