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
c5bb0692
Commit
c5bb0692
authored
Nov 03, 2020
by
Antoine Kaufmann
Browse files
experiments: checkpoint for python scripts
parent
62c6bed2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
8 deletions
+56
-8
experiments/modes/experiments.py
experiments/modes/experiments.py
+1
-5
experiments/pyexps/qemu_i40e_pair.py
experiments/pyexps/qemu_i40e_pair.py
+2
-3
experiments/run.py
experiments/run.py
+53
-0
No files found.
experiments/modes/experiments.py
View file @
c5bb0692
...
@@ -169,7 +169,7 @@ class ExpOutput(object):
...
@@ -169,7 +169,7 @@ class ExpOutput(object):
self
.
start_time
=
time
.
time
()
self
.
start_time
=
time
.
time
()
def
set_end
(
self
):
def
set_end
(
self
):
self
.
end
=
time
.
time
()
self
.
end
_time
=
time
.
time
()
def
set_failed
(
self
):
def
set_failed
(
self
):
self
.
success
=
False
self
.
success
=
False
...
@@ -189,9 +189,5 @@ class ExpOutput(object):
...
@@ -189,9 +189,5 @@ class ExpOutput(object):
def
run_exp_local
(
exp
,
env
):
def
run_exp_local
(
exp
,
env
):
if
os
.
path
.
exists
(
env
.
workdir
):
raise
Exception
(
'Workdir already exists'
)
os
.
mkdir
(
env
.
workdir
)
asyncio
.
run
(
exp
.
prepare
(
env
))
asyncio
.
run
(
exp
.
prepare
(
env
))
return
asyncio
.
run
(
exp
.
run
(
env
))
return
asyncio
.
run
(
exp
.
run
(
env
))
experiments/exp
eriments
.py
→
experiments/
py
exp
s/qemu_i40e_pair
.py
View file @
c5bb0692
...
@@ -32,6 +32,5 @@ for i in range (0, 2):
...
@@ -32,6 +32,5 @@ for i in range (0, 2):
host_b
.
add_nic
(
nic_b
)
host_b
.
add_nic
(
nic_b
)
e
.
add_host
(
host_b
)
e
.
add_host
(
host_b
)
env
=
exp
.
ExpEnv
(
'..'
,
'./work'
)
experiments
=
[
e
]
out
=
exp
.
run_exp_local
(
e
,
env
)
print
(
out
.
dumps
())
experiments/run.py
0 → 100644
View file @
c5bb0692
import
argparse
import
sys
import
os
import
importlib
import
modes.experiments
as
exp
def
mkdir_if_not_exists
(
path
):
if
not
os
.
path
.
exists
(
path
):
os
.
mkdir
(
path
)
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'experiments'
,
metavar
=
'EXP'
,
type
=
str
,
nargs
=
'+'
,
help
=
'An experiment file to run'
)
parser
.
add_argument
(
'--runs'
,
metavar
=
'N'
,
type
=
int
,
default
=
1
,
help
=
'Number of runs'
)
parser
.
add_argument
(
'--repo'
,
metavar
=
'DIR'
,
type
=
str
,
default
=
'..'
,
help
=
'Repo directory'
)
parser
.
add_argument
(
'--workdir'
,
metavar
=
'DIR'
,
type
=
str
,
default
=
'./out/'
,
help
=
'Work directory base'
)
parser
.
add_argument
(
'--outdir'
,
metavar
=
'DIR'
,
type
=
str
,
default
=
'./out/'
,
help
=
'Output directory base'
)
args
=
parser
.
parse_args
()
experiments
=
[]
for
path
in
args
.
experiments
:
modname
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
path
))[
0
]
spec
=
importlib
.
util
.
spec_from_file_location
(
modname
,
path
)
mod
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
mod
)
experiments
+=
mod
.
experiments
mkdir_if_not_exists
(
args
.
workdir
)
mkdir_if_not_exists
(
args
.
outdir
)
for
e
in
experiments
:
workdir_base
=
'%s/%s'
%
(
args
.
workdir
,
e
.
name
)
mkdir_if_not_exists
(
workdir_base
)
for
run
in
range
(
0
,
args
.
runs
):
outpath
=
'%s/%s-%d.json'
%
(
args
.
outdir
,
e
.
name
,
run
)
if
os
.
path
.
exists
(
outpath
):
print
(
'skip %s run %d'
%
(
e
.
name
,
run
))
continue
workdir
=
'%s/%d'
%
(
workdir_base
,
run
)
mkdir_if_not_exists
(
workdir
)
env
=
exp
.
ExpEnv
(
args
.
repo
,
workdir
)
out
=
exp
.
run_exp_local
(
e
,
env
)
with
open
(
outpath
,
'w'
)
as
f
:
f
.
write
(
out
.
dumps
())
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