Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
561c65a5
Commit
561c65a5
authored
Jun 24, 2022
by
Jonas Kaufmann
Committed by
Antoine Kaufmann
Jul 08, 2022
Browse files
fixes additional pytype issues
parent
07957f98
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
23 deletions
+25
-23
experiments/simbricks/exectools.py
experiments/simbricks/exectools.py
+2
-0
experiments/simbricks/runtime/common.py
experiments/simbricks/runtime/common.py
+3
-3
experiments/simbricks/simulator_utils.py
experiments/simbricks/simulator_utils.py
+7
-7
experiments/simbricks/simulators.py
experiments/simbricks/simulators.py
+13
-13
No files found.
experiments/simbricks/exectools.py
View file @
561c65a5
...
@@ -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
...
...
experiments/simbricks/runtime/common.py
View file @
561c65a5
...
@@ -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
...
...
experiments/simbricks/simulator_utils.py
View file @
561c65a5
...
@@ -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
):
):
...
...
experiments/simbricks/simulators.py
View file @
561c65a5
...
@@ -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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment