Commit 561c65a5 authored by Jonas Kaufmann's avatar Jonas Kaufmann Committed by Antoine Kaufmann
Browse files

fixes additional pytype issues

parent 07957f98
...@@ -186,6 +186,8 @@ class SimpleComponent(Component): ...@@ -186,6 +186,8 @@ class SimpleComponent(Component):
raise Exception('Command Failed: ' + str(self.cmd_parts)) raise Exception('Command Failed: ' + str(self.cmd_parts))
class SimpleRemoteComponent(SimpleComponent): class SimpleRemoteComponent(SimpleComponent):
pid_fut: asyncio.Future
def __init__(self, host_name, label, cmd_parts, cwd=None, ssh_extra_args=[], *args, **kwargs): def __init__(self, host_name, label, cmd_parts, cwd=None, ssh_extra_args=[], *args, **kwargs):
self.host_name = host_name self.host_name = host_name
self.extra_flags = ssh_extra_args self.extra_flags = ssh_extra_args
......
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Allow type annotation of class to be used in its own constructor # Allow own class to be used as type for a method's argument
from __future__ import annotations from __future__ import annotations
from abc import abstractmethod from abc import ABCMeta, abstractmethod
import shutil import shutil
import pathlib import pathlib
import typing as tp import typing as tp
...@@ -73,7 +73,7 @@ class Run(object): ...@@ -73,7 +73,7 @@ class Run(object):
await exec.mkdir(self.env.shm_base) await exec.mkdir(self.env.shm_base)
class Runtime(object): class Runtime(metaclass=ABCMeta):
"""Base class for managing the execution of multiple runs.""" """Base class for managing the execution of multiple runs."""
@abstractmethod @abstractmethod
......
...@@ -33,10 +33,10 @@ def create_basic_hosts( ...@@ -33,10 +33,10 @@ def create_basic_hosts(
num: int, num: int,
name_prefix: str, name_prefix: str,
net: NetSim, net: NetSim,
nic_class: NICSim, nic_class: tp.Type[NICSim],
host_class: HostSim, host_class: tp.Type[HostSim],
nc_class: NodeConfig, nc_class: tp.Type[NodeConfig],
app_class: AppConfig, app_class: tp.Type[AppConfig],
ip_start: int = 1, ip_start: int = 1,
ip_prefix: int = 24 ip_prefix: int = 24
): ):
...@@ -76,9 +76,9 @@ def create_multinic_hosts( ...@@ -76,9 +76,9 @@ def create_multinic_hosts(
num: int, num: int,
name_prefix: str, name_prefix: str,
net: NetSim, net: NetSim,
host_class: HostSim, host_class: tp.Type[HostSim],
nc_class: NodeConfig, nc_class: tp.Type[NodeConfig],
app_class: AppConfig, app_class: tp.Type[AppConfig],
ip_start: int = 1, ip_start: int = 1,
ip_prefix: int = 24 ip_prefix: int = 24
): ):
......
...@@ -20,6 +20,9 @@ ...@@ -20,6 +20,9 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# Allow own class to be used as type for a method's argument
from __future__ import annotations
import math import math
import typing as tp import typing as tp
...@@ -138,23 +141,20 @@ class NetSim(Simulator): ...@@ -138,23 +141,20 @@ class NetSim(Simulator):
sync_mode = 0 sync_mode = 0
sync_period = 500 sync_period = 500
eth_latency = 500 eth_latency = 500
nics: list[NICSim] = []
def __init__(self): hosts_direct: list[HostSim] = []
self.nics = [] net_listen: list[NetSim] = []
self.hosts_direct = [] net_connect: list[NetSim] = []
self.net_listen = []
self.net_connect = []
super().__init__()
def full_name(self): def full_name(self):
return 'net.' + self.name return 'net.' + self.name
def connect_network(self, net): def connect_network(self, net: NetSim):
"""Connect this network to the listening peer `net`""" """Connect this network to the listening peer `net`"""
net.net_listen.append(self) net.net_listen.append(self)
self.net_connect.append(net) self.net_connect.append(net)
def connect_sockets(self, env): def connect_sockets(self, env: ExpEnv):
sockets = [] sockets = []
for n in self.nics: for n in self.nics:
sockets.append((n, env.nic_eth_path(n))) sockets.append((n, env.nic_eth_path(n)))
...@@ -164,7 +164,7 @@ class NetSim(Simulator): ...@@ -164,7 +164,7 @@ class NetSim(Simulator):
sockets.append((h, env.net2host_eth_path(self, h))) sockets.append((h, env.net2host_eth_path(self, h)))
return sockets return sockets
def listen_sockets(self, env): def listen_sockets(self, env: ExpEnv):
listens = [] listens = []
for net in self.net_listen: for net in self.net_listen:
listens.append((net, env.n2n_eth_path(self, net))) listens.append((net, env.n2n_eth_path(self, net)))
...@@ -173,10 +173,10 @@ class NetSim(Simulator): ...@@ -173,10 +173,10 @@ class NetSim(Simulator):
def dependencies(self): def dependencies(self):
return self.nics + self.net_connect + self.hosts_direct return self.nics + self.net_connect + self.hosts_direct
def sockets_cleanup(self, env): def sockets_cleanup(self, env: ExpEnv):
return [s for (_,s) in self.listen_sockets(env)] return [s for (_,s) in self.listen_sockets(env)]
def sockets_wait(self, env): def sockets_wait(self, env: ExpEnv):
return [s for (_,s) in self.listen_sockets(env)] return [s for (_,s) in self.listen_sockets(env)]
...@@ -419,7 +419,7 @@ class MultiSubNIC(NICSim): ...@@ -419,7 +419,7 @@ class MultiSubNIC(NICSim):
def start_delay(self): def start_delay(self):
return 0 return 0
class I40eMultiNIC(Simulator): class I40eMultiNIC(Simulator): # TODO Fix typing, e.g., by making this a sublcass of NICSim
name = '' name = ''
def __init__(self): def __init__(self):
......
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