Commit b94393cf authored by Marvin Meiers's avatar Marvin Meiers Committed by Antoine Kaufmann
Browse files

experiments: make python linter and typechecker happy

parent 40d7535c
...@@ -139,10 +139,7 @@ for link_type in (E2ELinkType.NS3_SIMPLE_CHANNEL, E2ELinkType.SIMBRICKS): ...@@ -139,10 +139,7 @@ for link_type in (E2ELinkType.NS3_SIMPLE_CHANNEL, E2ELinkType.SIMBRICKS):
component.data_rate = f'{link_rate}Mbps' component.data_rate = f'{link_rate}Mbps'
component.queue_size = f'{queue_size}B' component.queue_size = f'{queue_size}B'
component.delay = f'{link_latency}ns' component.delay = f'{link_latency}ns'
elif isinstance( elif isinstance(component, (e2e.E2ENetworkSimbricks)):
component,
(e2e.E2ESimbricksNetworkNetIf, e2e.E2ESimbricksNetworkNicIf)
):
component.eth_latency = f'{link_latency}ns' component.eth_latency = f'{link_latency}ns'
# simbricks host # simbricks host
......
...@@ -116,7 +116,7 @@ class E2EGlobalConfig(E2EBase): ...@@ -116,7 +116,7 @@ class E2EGlobalConfig(E2EBase):
def ns3_config(self) -> str: def ns3_config(self) -> str:
self.mapping.update({ self.mapping.update({
"StopTime": self.stop_time, "MACStart": self.mac_start "StopTime": self.stop_time, "MACStart": str(self.mac_start)
}) })
return super().ns3_config() return super().ns3_config()
......
...@@ -187,7 +187,7 @@ class ExperimentBaseRunner(ABC): ...@@ -187,7 +187,7 @@ class ExperimentBaseRunner(ABC):
assert self.profile_int assert self.profile_int
while True: while True:
await asyncio.sleep(self.profile_int) await asyncio.sleep(self.profile_int)
for (sim,sc) in self.running: for (_,sc) in self.running:
await sc.sigusr1() await sc.sigusr1()
async def run(self) -> ExpOutput: async def run(self) -> ExpOutput:
...@@ -225,10 +225,10 @@ class ExperimentBaseRunner(ABC): ...@@ -225,10 +225,10 @@ class ExperimentBaseRunner(ABC):
traceback.print_exc() traceback.print_exc()
if profiler_task: if profiler_task:
try: try:
profiler_task.cancel() profiler_task.cancel()
except asyncio.CancelledError: except asyncio.CancelledError:
pass pass
# The bare except above guarantees that we always execute the following # The bare except above guarantees that we always execute the following
# code, which terminates all simulators and produces a proper output # code, which terminates all simulators and produces a proper output
# file. # file.
......
...@@ -111,4 +111,4 @@ class Runtime(metaclass=ABCMeta): ...@@ -111,4 +111,4 @@ class Runtime(metaclass=ABCMeta):
self.interrupt_handler() self.interrupt_handler()
def enable_profiler(self, profile_int: int) -> None: def enable_profiler(self, profile_int: int) -> None:
self.profile_int = profile_int self.profile_int = profile_int
\ No newline at end of file
...@@ -190,10 +190,10 @@ class NetSim(Simulator): ...@@ -190,10 +190,10 @@ class NetSim(Simulator):
self.eth_latency = 500 self.eth_latency = 500
"""Ethernet latency in nanoseconds from this network to connected """Ethernet latency in nanoseconds from this network to connected
components.""" components."""
self.nics: list[NICSim] = [] self.nics: tp.List[NICSim] = []
self.hosts_direct: list[HostSim] = [] self.hosts_direct: tp.List[HostSim] = []
self.net_listen: list[(NetSim, str)] = [] self.net_listen: tp.List[tp.Tuple[NetSim, str]] = []
self.net_connect: list[(NetSim, str)] = [] self.net_connect: tp.List[tp.Tuple[NetSim, str]] = []
self.wait = False self.wait = False
def full_name(self) -> str: def full_name(self) -> str:
...@@ -219,12 +219,12 @@ class NetSim(Simulator): ...@@ -219,12 +219,12 @@ class NetSim(Simulator):
def listen_sockets(self, env: ExpEnv) -> tp.List[tp.Tuple[NetSim, str]]: def listen_sockets(self, env: ExpEnv) -> tp.List[tp.Tuple[NetSim, str]]:
listens = [] listens = []
for (net,suffix) in self.net_listen: for (net, suffix) in self.net_listen:
listens.append((net, env.n2n_eth_path(self, net, suffix))) listens.append((net, env.n2n_eth_path(self, net, suffix)))
return listens return listens
def dependencies(self) -> tp.List[Simulator]: def dependencies(self) -> tp.List[Simulator]:
return self.nics + self.hosts_direct + [n for n,_ in self.net_connect] return self.nics + self.hosts_direct + [n for n, _ in self.net_connect]
def sockets_cleanup(self, env: ExpEnv) -> tp.List[str]: def sockets_cleanup(self, env: ExpEnv) -> tp.List[str]:
return [s for (_, s) in self.listen_sockets(env)] return [s for (_, s) in self.listen_sockets(env)]
...@@ -232,7 +232,7 @@ class NetSim(Simulator): ...@@ -232,7 +232,7 @@ class NetSim(Simulator):
def sockets_wait(self, env: ExpEnv) -> tp.List[str]: def sockets_wait(self, env: ExpEnv) -> tp.List[str]:
return [s for (_, s) in self.listen_sockets(env)] return [s for (_, s) in self.listen_sockets(env)]
def wait_terminate(self) -> Bool: def wait_terminate(self) -> bool:
return self.wait return self.wait
def init_network(self) -> None: def init_network(self) -> None:
...@@ -925,7 +925,7 @@ class NS3E2ENet(NetSim): ...@@ -925,7 +925,7 @@ class NS3E2ENet(NetSim):
def resolve_socket_paths( def resolve_socket_paths(
self, self,
env: ExpEnv, env: ExpEnv,
e2e_sim: tp.Union[e2e.E2ESimbricksNetwork, e2e.E2ESimbricksHost], e2e_sim: tp.Union[e2e.E2ENetworkSimbricks, e2e.E2ESimbricksHost],
listen: bool = False listen: bool = False
) -> None: ) -> None:
if e2e_sim.simbricks_component is None: if e2e_sim.simbricks_component is None:
...@@ -935,6 +935,10 @@ class NS3E2ENet(NetSim): ...@@ -935,6 +935,10 @@ class NS3E2ENet(NetSim):
if e2e_sim.adapter_type == e2e.SimbricksAdapterType.NIC: if e2e_sim.adapter_type == e2e.SimbricksAdapterType.NIC:
e2e_sim.unix_socket = env.nic_eth_path(e2e_sim.simbricks_component) e2e_sim.unix_socket = env.nic_eth_path(e2e_sim.simbricks_component)
elif e2e_sim.adapter_type == e2e.SimbricksAdapterType.NETWORK: elif e2e_sim.adapter_type == e2e.SimbricksAdapterType.NETWORK:
if not isinstance(e2e_sim, e2e.E2ENetworkSimbricks):
raise RuntimeError(
f'Expected {e2e_sim.id} to be of type E2ENetworkSimbricks'
)
p_suf = '' p_suf = ''
if e2e_sim.peer: if e2e_sim.peer:
p_suf = min(e2e_sim.name, e2e_sim.peer.name) p_suf = min(e2e_sim.name, e2e_sim.peer.name)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment