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
f7c0652d
Commit
f7c0652d
authored
Nov 03, 2020
by
Antoine Kaufmann
Browse files
experiments: support for running pickled experiments (prep for slurm)
parent
c5bb0692
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
experiments/run.py
experiments/run.py
+11
-5
No files found.
experiments/run.py
View file @
f7c0652d
...
@@ -2,6 +2,7 @@ import argparse
...
@@ -2,6 +2,7 @@ import argparse
import
sys
import
sys
import
os
import
os
import
importlib
import
importlib
import
pickle
import
modes.experiments
as
exp
import
modes.experiments
as
exp
def
mkdir_if_not_exists
(
path
):
def
mkdir_if_not_exists
(
path
):
...
@@ -24,11 +25,16 @@ args = parser.parse_args()
...
@@ -24,11 +25,16 @@ args = parser.parse_args()
experiments
=
[]
experiments
=
[]
for
path
in
args
.
experiments
:
for
path
in
args
.
experiments
:
modname
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
path
))[
0
]
modname
,
modext
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
path
))
spec
=
importlib
.
util
.
spec_from_file_location
(
modname
,
path
)
mod
=
importlib
.
util
.
module_from_spec
(
spec
)
if
modext
==
'.py'
:
spec
.
loader
.
exec_module
(
mod
)
spec
=
importlib
.
util
.
spec_from_file_location
(
modname
,
path
)
experiments
+=
mod
.
experiments
mod
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
mod
)
experiments
+=
mod
.
experiments
else
:
with
open
(
path
,
'rb'
)
as
f
:
experiments
.
append
(
pickle
.
load
(
f
))
mkdir_if_not_exists
(
args
.
workdir
)
mkdir_if_not_exists
(
args
.
workdir
)
mkdir_if_not_exists
(
args
.
outdir
)
mkdir_if_not_exists
(
args
.
outdir
)
...
...
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