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
6b3fc27f
Commit
6b3fc27f
authored
Nov 19, 2023
by
Jonas Kaufmann
Committed by
Antoine Kaufmann
Dec 05, 2023
Browse files
experiments/run.py: change imports to respect Python style guide
parent
0b3de18a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
30 deletions
+20
-30
experiments/run.py
experiments/run.py
+20
-30
No files found.
experiments/run.py
View file @
6b3fc27f
...
...
@@ -30,25 +30,14 @@ import importlib.util
import
json
import
os
import
pickle
import
signal
import
sys
import
typing
as
tp
from
signal
import
SIGINT
,
signal
from
simbricks.orchestration
import
exectools
from
simbricks.orchestration.exectools
import
LocalExecutor
,
RemoteExecutor
from
simbricks.orchestration.experiment.experiment_environment
import
ExpEnv
from
simbricks.orchestration.experiments
import
(
DistributedExperiment
,
Experiment
)
from
simbricks.orchestration.runtime
import
common
as
rt_common
from
simbricks.orchestration.runtime.common
import
Run
from
simbricks.orchestration.runtime.distributed
import
(
DistributedSimpleRuntime
,
auto_dist
)
from
simbricks.orchestration.runtime.local
import
(
LocalParallelRuntime
,
LocalSimpleRuntime
)
from
simbricks.orchestration.runtime.slurm
import
SlurmRuntime
from
simbricks.orchestration
import
experiments
as
exps
from
simbricks.orchestration
import
runtime
from
simbricks.orchestration.experiment
import
experiment_environment
def
parse_args
()
->
argparse
.
Namespace
:
...
...
@@ -238,9 +227,9 @@ def load_executors(path: str) -> tp.List[exectools.Executor]:
exs
=
[]
for
h
in
hosts
:
if
h
[
'type'
]
==
'local'
:
ex
=
LocalExecutor
()
ex
=
exectools
.
LocalExecutor
()
elif
h
[
'type'
]
==
'remote'
:
ex
=
RemoteExecutor
(
h
[
'host'
],
h
[
'workdir'
])
ex
=
exectools
.
RemoteExecutor
(
h
[
'host'
],
h
[
'workdir'
])
if
'ssh_args'
in
h
:
ex
.
ssh_extra_args
+=
h
[
'ssh_args'
]
if
'scp_args'
in
h
:
...
...
@@ -260,12 +249,11 @@ def warn_multi_exec(executors: tp.List[exectools.Executor]):
)
# pylint: disable=redefined-outer-name
def
add_exp
(
e
:
Experiment
,
rt
:
r
t_common
.
Runtime
,
e
:
exps
.
Experiment
,
rt
:
r
untime
.
Runtime
,
run
:
int
,
prereq
:
tp
.
Optional
[
Run
],
prereq
:
tp
.
Optional
[
runtime
.
Run
],
create_cp
:
bool
,
restore_cp
:
bool
,
no_simbricks
:
bool
,
...
...
@@ -281,7 +269,7 @@ def add_exp(
if
args
.
shmdir
is
not
None
:
shmdir
=
f
'
{
args
.
shmdir
}
/
{
e
.
name
}
/
{
run
}
'
env
=
ExpEnv
(
args
.
repo
,
workdir
,
cpdir
)
env
=
experiment_environment
.
ExpEnv
(
args
.
repo
,
workdir
,
cpdir
)
env
.
create_cp
=
create_cp
env
.
restore_cp
=
restore_cp
env
.
no_simbricks
=
no_simbricks
...
...
@@ -291,7 +279,7 @@ def add_exp(
if
args
.
shmdir
is
not
None
:
env
.
shm_base
=
os
.
path
.
abspath
(
shmdir
)
run
=
Run
(
e
,
run
,
env
,
outpath
,
prereq
)
run
=
runtime
.
Run
(
e
,
run
,
env
,
outpath
,
prereq
)
rt
.
add_run
(
run
)
return
run
...
...
@@ -306,19 +294,21 @@ def main():
# initialize runtime
if
args
.
runtime
==
'parallel'
:
warn_multi_exec
(
executors
)
rt
=
LocalParallelRuntime
(
rt
=
runtime
.
LocalParallelRuntime
(
cores
=
args
.
cores
,
mem
=
args
.
mem
,
verbose
=
args
.
verbose
,
executor
=
executors
[
0
]
)
elif
args
.
runtime
==
'slurm'
:
rt
=
SlurmRuntime
(
args
.
slurmdir
,
args
,
verbose
=
args
.
verbose
)
rt
=
runtime
.
SlurmRuntime
(
args
.
slurmdir
,
args
,
verbose
=
args
.
verbose
)
elif
args
.
runtime
==
'dist'
:
rt
=
DistributedSimpleRuntime
(
executors
,
verbose
=
args
.
verbose
)
rt
=
runtime
.
DistributedSimpleRuntime
(
executors
,
verbose
=
args
.
verbose
)
else
:
warn_multi_exec
(
executors
)
rt
=
LocalSimpleRuntime
(
verbose
=
args
.
verbose
,
executor
=
executors
[
0
])
rt
=
runtime
.
LocalSimpleRuntime
(
verbose
=
args
.
verbose
,
executor
=
executors
[
0
]
)
# load experiments
if
not
args
.
pickled
:
...
...
@@ -345,8 +335,8 @@ def main():
sys
.
exit
(
0
)
for
e
in
experiments
:
if
args
.
auto_dist
and
not
isinstance
(
e
,
DistributedExperiment
):
e
=
auto_dist
(
e
,
executors
,
args
.
proxy_type
)
if
args
.
auto_dist
and
not
isinstance
(
e
,
exps
.
DistributedExperiment
):
e
=
runtime
.
auto_dist
(
e
,
executors
,
args
.
proxy_type
)
# apply filter if any specified
if
(
args
.
filter
)
and
(
len
(
args
.
filter
)
>
0
):
match
=
False
...
...
@@ -379,7 +369,7 @@ def main():
rt
.
add_run
(
pickle
.
load
(
f
))
# register interrupt handler
signal
(
SIGINT
,
lambda
*
_
:
rt
.
interrupt
())
signal
.
signal
(
signal
.
SIGINT
,
lambda
*
_
:
rt
.
interrupt
())
# invoke runtime to run experiments
asyncio
.
run
(
rt
.
start
())
...
...
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