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):
component.data_rate = f'{link_rate}Mbps'
component.queue_size = f'{queue_size}B'
component.delay = f'{link_latency}ns'
elif isinstance(
component,
(e2e.E2ESimbricksNetworkNetIf, e2e.E2ESimbricksNetworkNicIf)
):
elif isinstance(component, (e2e.E2ENetworkSimbricks)):
component.eth_latency = f'{link_latency}ns'
# simbricks host
......
......@@ -116,7 +116,7 @@ class E2EGlobalConfig(E2EBase):
def ns3_config(self) -> str:
self.mapping.update({
"StopTime": self.stop_time, "MACStart": self.mac_start
"StopTime": self.stop_time, "MACStart": str(self.mac_start)
})
return super().ns3_config()
......
......@@ -187,7 +187,7 @@ class ExperimentBaseRunner(ABC):
assert self.profile_int
while True:
await asyncio.sleep(self.profile_int)
for (sim,sc) in self.running:
for (_,sc) in self.running:
await sc.sigusr1()
async def run(self) -> ExpOutput:
......@@ -225,10 +225,10 @@ class ExperimentBaseRunner(ABC):
traceback.print_exc()
if profiler_task:
try:
profiler_task.cancel()
except asyncio.CancelledError:
pass
try:
profiler_task.cancel()
except asyncio.CancelledError:
pass
# The bare except above guarantees that we always execute the following
# code, which terminates all simulators and produces a proper output
# file.
......
......@@ -111,4 +111,4 @@ class Runtime(metaclass=ABCMeta):
self.interrupt_handler()
def enable_profiler(self, profile_int: int) -> None:
self.profile_int = profile_int
\ No newline at end of file
self.profile_int = profile_int
......@@ -190,10 +190,10 @@ class NetSim(Simulator):
self.eth_latency = 500
"""Ethernet latency in nanoseconds from this network to connected
components."""
self.nics: list[NICSim] = []
self.hosts_direct: list[HostSim] = []
self.net_listen: list[(NetSim, str)] = []
self.net_connect: list[(NetSim, str)] = []
self.nics: tp.List[NICSim] = []
self.hosts_direct: tp.List[HostSim] = []
self.net_listen: tp.List[tp.Tuple[NetSim, str]] = []
self.net_connect: tp.List[tp.Tuple[NetSim, str]] = []
self.wait = False
def full_name(self) -> str:
......@@ -219,12 +219,12 @@ class NetSim(Simulator):
def listen_sockets(self, env: ExpEnv) -> tp.List[tp.Tuple[NetSim, str]]:
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)))
return listens
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]:
return [s for (_, s) in self.listen_sockets(env)]
......@@ -232,7 +232,7 @@ class NetSim(Simulator):
def sockets_wait(self, env: ExpEnv) -> tp.List[str]:
return [s for (_, s) in self.listen_sockets(env)]
def wait_terminate(self) -> Bool:
def wait_terminate(self) -> bool:
return self.wait
def init_network(self) -> None:
......@@ -925,7 +925,7 @@ class NS3E2ENet(NetSim):
def resolve_socket_paths(
self,
env: ExpEnv,
e2e_sim: tp.Union[e2e.E2ESimbricksNetwork, e2e.E2ESimbricksHost],
e2e_sim: tp.Union[e2e.E2ENetworkSimbricks, e2e.E2ESimbricksHost],
listen: bool = False
) -> None:
if e2e_sim.simbricks_component is None:
......@@ -935,6 +935,10 @@ class NS3E2ENet(NetSim):
if e2e_sim.adapter_type == e2e.SimbricksAdapterType.NIC:
e2e_sim.unix_socket = env.nic_eth_path(e2e_sim.simbricks_component)
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 = ''
if e2e_sim.peer:
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