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
8be8b838
Commit
8be8b838
authored
Nov 04, 2020
by
Antoine Kaufmann
Browse files
experiments: move runtime classes to separate file
parent
6256bd2e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
30 deletions
+33
-30
experiments/modes/runtime.py
experiments/modes/runtime.py
+31
-0
experiments/run.py
experiments/run.py
+2
-30
No files found.
experiments/modes/runtime.py
0 → 100644
View file @
8be8b838
import
modes.experiments
as
exp
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
())
experiments/run.py
View file @
8be8b838
...
@@ -4,40 +4,12 @@ import os
...
@@ -4,40 +4,12 @@ import os
import
importlib
import
importlib
import
pickle
import
pickle
import
modes.experiments
as
exp
import
modes.experiments
as
exp
import
modes.runtime
as
runtime
def
mkdir_if_not_exists
(
path
):
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
=
'+'
,
...
@@ -69,7 +41,7 @@ for path in args.experiments:
...
@@ -69,7 +41,7 @@ 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
()
runtime
=
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
)
...
...
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