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
ef040487
Unverified
Commit
ef040487
authored
Sep 25, 2024
by
Jakob Görgen
Browse files
path building and experiment fixes
parent
31b07726
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
12 deletions
+39
-12
experiments/run_new.py
experiments/run_new.py
+1
-1
experiments/simbricks/orchestration/instantiation/base.py
experiments/simbricks/orchestration/instantiation/base.py
+27
-7
experiments/simbricks/orchestration/simulation/base.py
experiments/simbricks/orchestration/simulation/base.py
+2
-1
experiments/simbricks/orchestration/simulation/host.py
experiments/simbricks/orchestration/simulation/host.py
+6
-1
experiments/simbricks/orchestration/system/host/disk_images.py
...iments/simbricks/orchestration/system/host/disk_images.py
+2
-1
experiments/simbricks/orchestration/utils/base.py
experiments/simbricks/orchestration/utils/base.py
+1
-1
No files found.
experiments/run_new.py
View file @
ef040487
...
...
@@ -300,7 +300,7 @@ def add_exp(
tmp_simulation_files
=
tmp_sim_files
,
)
inst_
=
inst_base
.
Instantiation
(
inst_env
)
inst_
=
inst_base
.
Instantiation
(
sim
=
simulation
,
env
=
inst_env
)
output_
=
output
.
SimulationOutput
(
simulation
)
run
=
runs
.
base
.
Run
(
simulation
=
simulation
,
...
...
experiments/simbricks/orchestration/instantiation/base.py
View file @
ef040487
...
...
@@ -123,6 +123,7 @@ class Instantiation(util_base.IdObj):
self
.
_env
:
InstantiationEnvironment
=
env
self
.
_executor
:
command_executor
.
Executor
|
None
=
None
self
.
_socket_per_interface
:
dict
[
sys_base
.
Interface
,
Socket
]
=
{}
self
.
_simulation_topo
:
dict
[]
@
staticmethod
def
is_absolute_exists
(
path
:
str
)
->
bool
:
...
...
@@ -253,6 +254,19 @@ class Instantiation(util_base.IdObj):
self
.
_updated_tracker_mapping
(
interface
=
interface
,
socket
=
new_socket
)
return
new_socket
def
_build_simulation_topology
(
self
)
->
None
:
# TODO: FIXME
def
sim_graph
(
self
)
->
dict
[
sim_base
.
Simulator
,
set
[
sim_base
.
Simulator
]]:
sims
=
self
.
_simulation
.
all_simulators
()
graph
=
{}
for
sim
in
sims
:
deps
=
sim
.
dependencies
()
+
sim
.
extra_deps
print
(
f
'deps of
{
sim
}
:
{
sim
.
dependencies
()
}
'
)
graph
[
sim
]
=
set
()
for
d
in
deps
:
graph
[
sim
].
add
(
d
)
return
graph
async
def
cleanup_sockets
(
self
,
sockets
:
list
[
Socket
]
=
[],
...
...
@@ -318,9 +332,14 @@ class Instantiation(util_base.IdObj):
def
_join_paths
(
self
,
base
:
str
=
""
,
relative_path
:
str
=
""
,
enforce_existence
=
False
)
->
str
:
path
=
pathlib
.
Path
(
base
)
joined
=
path
.
joinpath
(
relative_path
)
if
not
joined
.
exists
()
and
enforce_existence
:
if
relative_path
.
startswith
(
"/"
):
raise
Exception
(
f
"cannot join with base=
{
base
}
because relative_path=
{
relative_path
}
starts with '/'"
)
joined
=
pathlib
.
Path
(
base
).
joinpath
(
relative_path
)
print
(
f
"joined=
{
joined
}
"
)
if
enforce_existence
and
not
joined
.
exists
():
raise
Exception
(
f
"couldn't join
{
base
}
and
{
relative_path
}
"
)
return
joined
.
absolute
()
...
...
@@ -341,7 +360,7 @@ class Instantiation(util_base.IdObj):
return
hd_name_or_path
path
=
self
.
_join_paths
(
base
=
self
.
_env
.
_repodir
,
relative_path
=
f
"
/
images/output-
{
hd_name_or_path
}
/
{
hd_name_or_path
}
"
,
relative_path
=
f
"images/output-
{
hd_name_or_path
}
/
{
hd_name_or_path
}
"
,
enforce_existence
=
True
,
)
return
path
...
...
@@ -356,21 +375,21 @@ class Instantiation(util_base.IdObj):
)
def
dynamic_img_path
(
self
,
img
:
disk_images
.
DiskImage
,
format
:
str
)
->
str
:
filename
=
img
.
_id
+
"."
+
format
filename
=
f
"
{
img
.
_id
}
.
{
format
}
"
return
self
.
_join_paths
(
base
=
self
.
_env
.
_tmp_simulation_files
,
relative_path
=
filename
,
)
def
hdcopy_path
(
self
,
img
:
disk_images
.
DiskImage
,
format
:
str
)
->
str
:
filename
=
img
.
_id
+
"
_hdcopy
"
"."
+
format
filename
=
f
"
{
img
.
_id
}
_hdcopy
.
{
format
}
"
return
self
.
_join_paths
(
base
=
self
.
_env
.
_tmp_simulation_files
,
relative_path
=
filename
,
)
def
cpdir_subdir
(
self
,
sim
:
sim_base
.
Simulator
)
->
str
:
dir_path
=
f
"
/
checkpoint.
{
sim
.
name
}
-
{
sim
.
_id
}
"
dir_path
=
f
"checkpoint.
{
sim
.
name
}
-
{
sim
.
_id
}
"
return
self
.
_join_paths
(
base
=
self
.
cpdir
(),
relative_path
=
dir_path
,
enforce_existence
=
False
)
...
...
@@ -382,4 +401,5 @@ class Instantiation(util_base.IdObj):
)
def
find_sim_by_spec
(
self
,
spec
:
sys_host
.
FullSystemHost
)
->
sim_base
.
Simulator
:
util_base
.
has_expected_type
(
spec
,
sys_host
.
FullSystemHost
)
return
self
.
_simulation
.
find_sim
(
spec
)
experiments/simbricks/orchestration/simulation/base.py
View file @
ef040487
...
...
@@ -331,8 +331,9 @@ class Simulation(utils_base.IdObj):
def
find_sim
(
self
,
comp
:
sys_conf
.
Component
)
->
sim_base
.
Simulator
:
"""Returns the used simulator object for the system component."""
utils_base
.
has_expected_type
(
comp
,
sys_conf
.
Component
)
if
comp
not
in
self
.
_sys_sim_map
:
raise
Exception
(
"Simulator
N
ot
F
ound"
)
raise
Exception
(
f
"Simulator
n
ot
f
ound
for component:
{
comp
}
"
)
return
self
.
_sys_sim_map
[
comp
]
async
def
prepare
(
self
,
inst
:
inst_base
.
Instantiation
)
->
None
:
...
...
experiments/simbricks/orchestration/simulation/host.py
View file @
ef040487
...
...
@@ -48,7 +48,7 @@ class HostSim(sim_base.Simulator):
def
config_str
(
self
)
->
str
:
return
[]
def
supported_image_formats
()
->
list
[
str
]:
def
supported_image_formats
(
self
)
->
list
[
str
]:
raise
Exception
(
"implement me"
)
...
...
@@ -71,6 +71,9 @@ class Gem5Sim(HostSim):
def
resreq_mem
(
self
)
->
int
:
return
4096
def
supported_image_formats
(
self
)
->
list
[
str
]:
return
[
"raw"
]
async
def
prepare
(
self
,
inst
:
inst_base
.
Instantiation
)
->
None
:
await
super
().
prepare
(
inst
=
inst
)
...
...
@@ -142,6 +145,8 @@ class QemuSim(HostSim):
def
resreq_mem
(
self
)
->
int
:
return
8192
def
supported_image_formats
(
self
)
->
list
[
str
]:
return
[
"raw"
,
"qcow2"
]
async
def
prepare
(
self
,
inst
:
inst_base
.
Instantiation
)
->
None
:
await
super
().
prepare
(
inst
=
inst
)
...
...
experiments/simbricks/orchestration/system/host/disk_images.py
View file @
ef040487
...
...
@@ -36,7 +36,8 @@ if tp.TYPE_CHECKING:
class
DiskImage
(
utils_base
.
IdObj
):
def
__init__
(
self
,
h
:
sys_host
.
Host
)
->
None
:
self
.
host
=
None
|
str
super
().
__init__
()
self
.
host
:
sys_host
.
Host
=
h
@
abc
.
abstractmethod
def
available_formats
(
self
)
->
list
[
str
]:
...
...
experiments/simbricks/orchestration/utils/base.py
View file @
ef040487
...
...
@@ -43,5 +43,5 @@ def check_type(obj, expected_type) -> bool:
def
has_expected_type
(
obj
,
expected_type
)
->
None
:
if
not
check_type
(
obj
=
obj
,
expected_type
=
expected_type
):
raise
Exception
(
f
"obj of type
{
type
(
obj
)
}
has not the type or is not a subtype of
{
type
(
expected_type
)
}
"
f
"obj of type
{
type
(
obj
)
}
has not the type or is not a subtype of
{
expected_type
}
"
)
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