Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
thermac-opencl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
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
Eduard Lavuš
thermac-opencl
Commits
9b9b1f44
Commit
9b9b1f44
authored
2 years ago
by
Eduard Lavuš
Browse files
Options
Downloads
Patches
Plain Diff
experiments: add start and end indices to runner
parent
0b1c5f11
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
experiments/runner/runner.py
+27
-14
27 additions, 14 deletions
experiments/runner/runner.py
with
27 additions
and
14 deletions
experiments/runner/runner.py
+
27
−
14
View file @
9b9b1f44
...
@@ -202,12 +202,6 @@ class Measurement(DefinitionBase):
...
@@ -202,12 +202,6 @@ class Measurement(DefinitionBase):
def
__str__
(
self
):
def
__str__
(
self
):
return
f
"
Measurement(
{
self
.
name
}
,
\n
{
self
.
runner
}
,
\n
{
self
.
experiment
}
,
\n
{
self
.
parameters
}
)
"
return
f
"
Measurement(
{
self
.
name
}
,
\n
{
self
.
runner
}
,
\n
{
self
.
experiment
}
,
\n
{
self
.
parameters
}
)
"
def
__enter__
(
self
):
self
.
_setup
()
def
__exit__
(
self
,
exc_type
,
exc_value
,
traceback
):
self
.
_teardown
()
@staticmethod
@staticmethod
def
_apply_fan_speed
(
speed
):
def
_apply_fan_speed
(
speed
):
subprocess
.
run
(
subprocess
.
run
(
...
@@ -309,12 +303,20 @@ class Measurement(DefinitionBase):
...
@@ -309,12 +303,20 @@ class Measurement(DefinitionBase):
yield
self
.
runner
.
parameters
.
copy
().
merge
(
self
.
experiment
.
parameters
).
merge
(
parameters
)
yield
self
.
runner
.
parameters
.
copy
().
merge
(
self
.
experiment
.
parameters
).
merge
(
parameters
)
# TODO: allow_continue for _execute
def
run
(
self
,
dry_run
=
False
,
combination_range
=
(
0
,
-
1
)):
def
run
(
self
,
dry_run
=
False
,
allow_continue
=
False
):
start_index
=
combination_range
[
0
]
end_index
=
combination_range
[
1
]
if
end_index
==
0
:
end_index
=
None
allow_continue
=
start_index
!=
0
or
end_index
is
not
None
if
not
dry_run
:
if
not
dry_run
:
self
.
_setup
(
allow_continue
)
self
.
_setup
(
allow_continue
=
allow_continue
)
for
parameters
in
self
.
_generate_execution_parameters
():
combinations
=
list
(
self
.
_generate_execution_parameters
())
if
allow_continue
:
self
.
_log
(
f
"
Skipping combinations outside range (
{
start_index
}
,
{
end_index
}
)
"
)
for
parameters
in
combinations
[
start_index
:
end_index
]:
command
=
self
.
runner
.
prepare_command
(
parameters
)
+
self
.
experiment
.
prepare_command
(
parameters
)
+
self
.
prepare_command
(
parameters
)
command
=
self
.
runner
.
prepare_command
(
parameters
)
+
self
.
experiment
.
prepare_command
(
parameters
)
+
self
.
prepare_command
(
parameters
)
env
=
self
.
runner
.
prepare_environment
(
parameters
).
merge
(
self
.
experiment
.
prepare_environment
(
parameters
)).
merge
(
self
.
prepare_environment
(
parameters
))
env
=
self
.
runner
.
prepare_environment
(
parameters
).
merge
(
self
.
experiment
.
prepare_environment
(
parameters
)).
merge
(
self
.
prepare_environment
(
parameters
))
...
@@ -389,7 +391,8 @@ def try_notif(message, dry_run = False):
...
@@ -389,7 +391,8 @@ def try_notif(message, dry_run = False):
def
main
(
def
main
(
definitions_path
,
definitions_path
,
measurement_name
=
None
,
measurement_name
=
None
,
dry_run
=
False
dry_run
=
False
,
combination_range
=
(
0
,
-
1
)
):
):
definitions
=
None
definitions
=
None
with
open
(
definitions_path
,
"
r
"
)
as
file
:
with
open
(
definitions_path
,
"
r
"
)
as
file
:
...
@@ -406,8 +409,8 @@ def main(
...
@@ -406,8 +409,8 @@ def main(
measurement
=
measurements
[
measurement_name
]
measurement
=
measurements
[
measurement_name
]
try_notif
(
f
"
Starting measurement
\"
{
measurement_name
}
\"
"
,
dry_run
=
dry_run
)
try_notif
(
f
"
Starting measurement
\"
{
measurement_name
}
\"
(range
{
combination_range
}
)
"
,
dry_run
=
dry_run
)
measurement
.
run
(
dry_run
=
dry_run
)
measurement
.
run
(
dry_run
=
dry_run
,
combination_range
=
combination_range
)
try_notif
(
f
"
Done measurement
\"
{
measurement_name
}
\"
"
,
dry_run
=
dry_run
)
try_notif
(
f
"
Done measurement
\"
{
measurement_name
}
\"
"
,
dry_run
=
dry_run
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
@@ -422,6 +425,16 @@ if __name__ == "__main__":
...
@@ -422,6 +425,16 @@ if __name__ == "__main__":
action
=
"
store_true
"
,
action
=
"
store_true
"
,
help
=
"
Don
'
t actually run anything, only print what would happen.
"
help
=
"
Don
'
t actually run anything, only print what would happen.
"
)
)
parser
.
add_argument
(
"
--start-index
"
,
dest
=
"
START_INDEX
"
,
type
=
int
,
default
=
0
,
help
=
"
Start from the given index of parameter combinations.
"
)
parser
.
add_argument
(
"
--end-index
"
,
dest
=
"
END_INDEX
"
,
type
=
int
,
default
=
0
,
help
=
"
End at the given index of parameter combinations.
"
)
parser
.
add_argument
(
parser
.
add_argument
(
"
MEASUREMENT
"
,
"
MEASUREMENT
"
,
default
=
None
,
nargs
=
"
?
"
,
default
=
None
,
nargs
=
"
?
"
,
...
@@ -429,4 +442,4 @@ if __name__ == "__main__":
...
@@ -429,4 +442,4 @@ if __name__ == "__main__":
)
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
main
(
args
.
DEFINITIONS
,
args
.
MEASUREMENT
,
dry_run
=
args
.
DRY_RUN
)
main
(
args
.
DEFINITIONS
,
args
.
MEASUREMENT
,
dry_run
=
args
.
DRY_RUN
,
combination_range
=
(
args
.
START_INDEX
,
args
.
END_INDEX
)
)
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