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
6256bd2e
"vscode:/vscode.git/clone" did not exist on "07c0fe4b87a07fc1b42bac738f013b78833559ae"
Commit
6256bd2e
authored
Nov 03, 2020
by
Antoine Kaufmann
Browse files
experiments: refactoring for adding slurm and parallel run support
parent
f7c0652d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
3 deletions
+34
-3
experiments/run.py
experiments/run.py
+34
-3
No files found.
experiments/run.py
View file @
6256bd2e
...
@@ -9,6 +9,36 @@ def mkdir_if_not_exists(path):
...
@@ -9,6 +9,36 @@ def mkdir_if_not_exists(path):
if
not
os
.
path
.
exists
(
path
):
if
not
os
.
path
.
exists
(
path
):
os
.
mkdir
(
path
)
os
.
mkdir
(
path
)
class
Run
(
object
):
def
__init__
(
self
,
experiment
,
env
,
outpath
):
self
.
experiment
=
experiment
self
.
env
=
env
self
.
outpath
=
outpath
self
.
output
=
None
class
Runtime
(
object
):
def
add_run
(
self
,
run
):
pass
def
start
(
self
):
pass
class
LocalSimpleRuntime
(
Runtime
):
def
__init__
(
self
):
self
.
runnable
=
[]
self
.
complete
=
[]
def
add_run
(
self
,
run
):
self
.
runnable
.
append
(
run
)
def
start
(
self
):
for
run
in
self
.
runnable
:
run
.
output
=
exp
.
run_exp_local
(
run
.
experiment
,
run
.
env
)
self
.
complete
.
append
(
run
)
with
open
(
run
.
outpath
,
'w'
)
as
f
:
f
.
write
(
run
.
output
.
dumps
())
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'experiments'
,
metavar
=
'EXP'
,
type
=
str
,
nargs
=
'+'
,
parser
.
add_argument
(
'experiments'
,
metavar
=
'EXP'
,
type
=
str
,
nargs
=
'+'
,
help
=
'An experiment file to run'
)
help
=
'An experiment file to run'
)
...
@@ -39,6 +69,8 @@ for path in args.experiments:
...
@@ -39,6 +69,8 @@ for path in args.experiments:
mkdir_if_not_exists
(
args
.
workdir
)
mkdir_if_not_exists
(
args
.
workdir
)
mkdir_if_not_exists
(
args
.
outdir
)
mkdir_if_not_exists
(
args
.
outdir
)
runtime
=
LocalSimpleRuntime
()
for
e
in
experiments
:
for
e
in
experiments
:
workdir_base
=
'%s/%s'
%
(
args
.
workdir
,
e
.
name
)
workdir_base
=
'%s/%s'
%
(
args
.
workdir
,
e
.
name
)
mkdir_if_not_exists
(
workdir_base
)
mkdir_if_not_exists
(
workdir_base
)
...
@@ -53,7 +85,6 @@ for e in experiments:
...
@@ -53,7 +85,6 @@ for e in experiments:
mkdir_if_not_exists
(
workdir
)
mkdir_if_not_exists
(
workdir
)
env
=
exp
.
ExpEnv
(
args
.
repo
,
workdir
)
env
=
exp
.
ExpEnv
(
args
.
repo
,
workdir
)
out
=
exp
.
run_exp_local
(
e
,
env
)
runtime
.
add_run
(
Run
(
e
,
env
,
outpath
)
)
with
open
(
outpath
,
'w'
)
as
f
:
runtime
.
start
()
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