Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
exp-runner
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christopher Spinrath
exp-runner
Commits
96d57e3c
Commit
96d57e3c
authored
1 month ago
by
Christopher Spinrath
Browse files
Options
Downloads
Patches
Plain Diff
Make timeouts configurable
parent
f722be81
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
run-exp.py
+21
-7
21 additions, 7 deletions
run-exp.py
with
21 additions
and
7 deletions
run-exp.py
+
21
−
7
View file @
96d57e3c
...
@@ -60,11 +60,12 @@ class Variable:
...
@@ -60,11 +60,12 @@ class Variable:
class
Task
:
class
Task
:
def
__init__
(
self
,
name
,
work_dir
,
base_command
,
parameters
):
def
__init__
(
self
,
name
,
work_dir
,
base_command
,
parameters
,
timeout
):
self
.
_name
=
name
self
.
_name
=
name
self
.
_work_dir
=
work_dir
self
.
_work_dir
=
work_dir
self
.
_base_command
=
base_command
self
.
_base_command
=
base_command
self
.
_parameters
=
parameters
self
.
_parameters
=
parameters
self
.
_timeout
=
timeout
@property
@property
def
name
(
self
):
def
name
(
self
):
...
@@ -74,8 +75,12 @@ class Task:
...
@@ -74,8 +75,12 @@ class Task:
def
work_dir
(
self
):
def
work_dir
(
self
):
return
self
.
_work_dir
return
self
.
_work_dir
def
run
(
self
,
variables
):
def
run
(
self
,
variables
,
global_timeout
,
dry_run
):
args
=
[
self
.
_base_command
]
if
dry_run
:
args
=
[
"
echo
"
]
else
:
args
=
[]
args
.
append
(
self
.
_base_command
)
for
p
in
self
.
_parameters
:
for
p
in
self
.
_parameters
:
if
not
isinstance
(
p
,
dict
):
if
not
isinstance
(
p
,
dict
):
...
@@ -102,13 +107,18 @@ class Task:
...
@@ -102,13 +107,18 @@ class Task:
# print(f"pushd {self._work_dir}")
# print(f"pushd {self._work_dir}")
# print(" ".join(args))
# print(" ".join(args))
# print("popd")
# print("popd")
timeout
=
self
.
_timeout
if
timeout
is
not
None
and
global_timeout
is
not
None
:
timeout
=
min
(
timeout
,
global_timeout
)
elif
global_timeout
is
not
None
:
timeout
=
global_timeout
try
:
try
:
subprocess
.
run
(
subprocess
.
run
(
"
"
.
join
(
args
),
"
"
.
join
(
args
),
shell
=
True
,
shell
=
True
,
cwd
=
self
.
_work_dir
,
cwd
=
self
.
_work_dir
,
timeout
=
3600
,
# FIXME
timeout
=
timeout
,
)
)
return
False
return
False
...
@@ -128,6 +138,8 @@ class Task:
...
@@ -128,6 +138,8 @@ class Task:
parameters
=
data
.
get
(
"
parameters
"
,
[])
parameters
=
data
.
get
(
"
parameters
"
,
[])
timeout
=
data
.
get
(
"
timeout
"
,
None
)
if
"
work-dir
"
in
data
:
if
"
work-dir
"
in
data
:
work_dir
=
pathlib
.
Path
(
data
[
"
work-dir
"
]).
expanduser
()
work_dir
=
pathlib
.
Path
(
data
[
"
work-dir
"
]).
expanduser
()
else
:
else
:
...
@@ -135,7 +147,7 @@ class Task:
...
@@ -135,7 +147,7 @@ class Task:
assert
work_dir
.
exists
(),
f
"
Working directory
\"
{
work_dir
}
\"
for task
\"
{
name
}
\"
does not exist!
"
assert
work_dir
.
exists
(),
f
"
Working directory
\"
{
work_dir
}
\"
for task
\"
{
name
}
\"
does not exist!
"
return
cls
(
name
,
work_dir
,
base_command
,
parameters
)
return
cls
(
name
,
work_dir
,
base_command
,
parameters
,
timeout
)
class
Config
:
class
Config
:
...
@@ -177,7 +189,9 @@ class Config:
...
@@ -177,7 +189,9 @@ class Config:
@click.command
()
@click.command
()
@click.argument
(
"
config_file
"
,
type
=
click
.
Path
(
@click.argument
(
"
config_file
"
,
type
=
click
.
Path
(
exists
=
True
,
file_okay
=
True
,
dir_okay
=
False
,
readable
=
True
,
path_type
=
pathlib
.
Path
))
exists
=
True
,
file_okay
=
True
,
dir_okay
=
False
,
readable
=
True
,
path_type
=
pathlib
.
Path
))
def
main
(
config_file
):
@click.option
(
"
--global-timeout
"
,
type
=
click
.
IntRange
(
1
),
default
=
7200
)
@click.option
(
"
--dry-run
"
,
is_flag
=
True
)
def
main
(
config_file
,
global_timeout
,
dry_run
):
c
=
Config
.
from_file
(
config_file
)
c
=
Config
.
from_file
(
config_file
)
print
(
f
"
> Running experiment
\"
{
c
.
name
}
\"
"
)
print
(
f
"
> Running experiment
\"
{
c
.
name
}
\"
"
)
...
@@ -202,7 +216,7 @@ def main(config_file):
...
@@ -202,7 +216,7 @@ def main(config_file):
for
task
in
c
.
tasks
:
for
task
in
c
.
tasks
:
print
(
f
"
Running task
{
task
.
name
}
"
)
print
(
f
"
Running task
{
task
.
name
}
"
)
timed_out
=
task
.
run
(
variables
)
timed_out
=
task
.
run
(
variables
,
global_timeout
,
dry_run
)
print
()
print
()
if
timed_out
:
# repetitions are useless if tasks time out
if
timed_out
:
# repetitions are useless if tasks time out
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment