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
710f659b
Commit
710f659b
authored
Nov 04, 2020
by
Antoine Kaufmann
Browse files
experiments: move mkdirs into runtime to avoid special casing for slurm
parent
32fd378d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
11 deletions
+10
-11
experiments/modes/nodeconfig.py
experiments/modes/nodeconfig.py
+1
-0
experiments/modes/runtime.py
experiments/modes/runtime.py
+7
-0
experiments/run.py
experiments/run.py
+2
-11
No files found.
experiments/modes/nodeconfig.py
View file @
710f659b
import
tarfile
import
io
import
pathlib
class
NodeConfig
(
object
):
sim
=
'qemu'
...
...
experiments/modes/runtime.py
View file @
710f659b
...
...
@@ -37,10 +37,13 @@ class LocalSimpleRuntime(Runtime):
def
start
(
self
):
for
run
in
self
.
runnable
:
pathlib
.
Path
(
run
.
env
.
workdir
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
run
.
output
=
exp
.
run_exp_local
(
run
.
experiment
,
run
.
env
,
verbose
=
self
.
verbose
)
self
.
complete
.
append
(
run
)
pathlib
.
Path
(
run
.
outpath
).
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
with
open
(
run
.
outpath
,
'w'
)
as
f
:
f
.
write
(
run
.
output
.
dumps
())
...
...
@@ -68,9 +71,13 @@ class LocalParallelRuntime(Runtime):
async
def
do_run
(
self
,
run
):
''' actually starts a run '''
pathlib
.
Path
(
run
.
env
.
workdir
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
await
run
.
experiment
.
prepare
(
run
.
env
,
verbose
=
self
.
verbose
)
print
(
'starting run '
,
run
.
name
())
run
.
output
=
await
run
.
experiment
.
run
(
run
.
env
,
verbose
=
self
.
verbose
)
pathlib
.
Path
(
run
.
outpath
).
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
with
open
(
run
.
outpath
,
'w'
)
as
f
:
f
.
write
(
run
.
output
.
dumps
())
print
(
'finished run '
,
run
.
name
())
...
...
experiments/run.py
View file @
710f659b
...
...
@@ -62,10 +62,6 @@ for path in args.experiments:
with
open
(
path
,
'rb'
)
as
f
:
experiments
.
append
(
pickle
.
load
(
f
))
if
args
.
runtime
!=
'slurm'
:
mkdir_if_not_exists
(
args
.
workdir
)
mkdir_if_not_exists
(
args
.
outdir
)
if
args
.
runtime
==
'parallel'
:
rt
=
runtime
.
LocalParallelRuntime
(
cores
=
args
.
cores
,
mem
=
args
.
mem
,
verbose
=
args
.
verbose
)
...
...
@@ -74,20 +70,15 @@ elif args.runtime == 'slurm':
else
:
rt
=
runtime
.
LocalSimpleRuntime
(
verbose
=
args
.
verbose
)
for
e
in
experiments
:
workdir_base
=
'%s/%s'
%
(
args
.
workdir
,
e
.
name
)
if
args
.
runtime
!=
'slurm'
:
mkdir_if_not_exists
(
workdir_base
)
for
e
in
experiments
:
for
run
in
range
(
args
.
firstrun
,
args
.
firstrun
+
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
)
if
args
.
runtime
!=
'slurm'
:
mkdir_if_not_exists
(
workdir
)
workdir
=
'%s/%s/%d'
%
(
args
.
workdir
,
e
.
name
,
run
)
env
=
exp
.
ExpEnv
(
args
.
repo
,
workdir
)
rt
.
add_run
(
runtime
.
Run
(
e
,
run
,
env
,
outpath
))
...
...
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