Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
theodolite
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
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sören Henning
theodolite
Commits
e036e5e5
Commit
e036e5e5
authored
4 years ago
by
Björn Vonheiden
Browse files
Options
Downloads
Patches
Plain Diff
Use argparse for cli arguments in theodolite.py
parent
ce80e459
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!44
Enhanced CLI arguments for theodolite
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
execution/theodolite.py
+96
-44
96 additions, 44 deletions
execution/theodolite.py
with
96 additions
and
44 deletions
execution/theodolite.py
+
96
−
44
View file @
e036e5e5
#!/usr/bin/env python
#!/usr/bin/env python
import
argparse
import
logging
# logging
import
logging
# logging
import
os
import
os
import
sys
import
sys
...
@@ -14,21 +15,68 @@ import strategies.subexperiment_execution.subexperiment_executor as subexperimen
...
@@ -14,21 +15,68 @@ import strategies.subexperiment_execution.subexperiment_executor as subexperimen
import
strategies.subexperiment_evaluation.subexperiment_evaluator
as
subexperiment_evaluator
import
strategies.subexperiment_evaluation.subexperiment_evaluator
as
subexperiment_evaluator
def
main
():
def
load_variables
():
uc
=
sys
.
argv
[
1
]
"""
Load the CLI variables given at the command line
"""
dim_values
=
sys
.
argv
[
2
].
split
(
'
,
'
)
print
(
'
Load CLI variables
'
)
replicas
=
sys
.
argv
[
3
].
split
(
'
,
'
)
parser
=
argparse
.
ArgumentParser
(
description
=
'
Run use case Programm
'
)
partitions
=
sys
.
argv
[
4
]
if
len
(
sys
.
argv
)
>=
5
and
sys
.
argv
[
4
]
else
40
parser
.
add_argument
(
'
uc
'
,
cpu_limit
=
sys
.
argv
[
5
]
if
len
(
sys
.
argv
)
>=
6
and
sys
.
argv
[
5
]
else
"
1000m
"
metavar
=
'
<uc>
'
,
memory_limit
=
sys
.
argv
[
6
]
if
len
(
sys
.
argv
)
>=
7
and
sys
.
argv
[
6
]
else
"
4Gi
"
help
=
'
use case number, one of 1, 2, 3 or 4
'
)
kafka_streams_commit_interval_ms
=
sys
.
argv
[
7
]
if
len
(
parser
.
add_argument
(
'
loads
'
,
sys
.
argv
)
>=
8
and
sys
.
argv
[
7
]
else
100
type
=
int
,
execution_minutes
=
sys
.
argv
[
8
]
if
len
(
metavar
=
'
<load>
'
,
sys
.
argv
)
>=
9
and
sys
.
argv
[
8
]
else
5
nargs
=
'
+
'
,
domain_restriction
=
bool
(
sys
.
argv
[
9
])
if
len
(
help
=
'
Loads that should be executed
'
)
sys
.
argv
)
>=
10
and
sys
.
argv
[
9
]
==
"
restrict-domain
"
else
False
parser
.
add_argument
(
'
--instances
'
,
'
-i
'
,
search_strategy
=
sys
.
argv
[
10
]
if
len
(
sys
.
argv
)
>=
11
and
(
dest
=
'
instances_list
'
,
sys
.
argv
[
10
]
==
"
linear-search
"
or
sys
.
argv
[
10
]
==
"
binary-search
"
)
else
"
default
"
default
=
[
1
],
type
=
int
,
metavar
=
'
<instance>
'
,
nargs
=
'
+
'
,
help
=
'
List of instances used in benchmarks
'
)
parser
.
add_argument
(
'
--partitions
'
,
'
-p
'
,
default
=
40
,
type
=
int
,
metavar
=
'
<partitions>
'
,
help
=
'
Number of partitions for Kafka topics
'
)
parser
.
add_argument
(
'
--cpu-limit
'
,
'
-cpu
'
,
default
=
'
1000m
'
,
metavar
=
'
<CPU limit>
'
,
help
=
'
Kubernetes CPU limit
'
)
parser
.
add_argument
(
'
--memory-limit
'
,
'
-mem
'
,
default
=
'
4Gi
'
,
metavar
=
'
<memory limit>
'
,
help
=
'
Kubernetes memory limit
'
)
parser
.
add_argument
(
'
--commit-ms
'
,
default
=
100
,
type
=
int
,
metavar
=
'
<commit ms>
'
,
help
=
'
Kafka Streams commit interval in milliseconds
'
)
parser
.
add_argument
(
'
--duration
'
,
'
-d
'
,
default
=
5
,
type
=
int
,
metavar
=
'
<duration>
'
,
help
=
'
Duration in minutes subexperiments should be
\
executed for
'
)
parser
.
add_argument
(
'
--domain-restriction
'
,
action
=
"
store_true
"
,
help
=
'
To use domain restriction. For details see README
'
)
parser
.
add_argument
(
'
--search-strategy
'
,
default
=
'
default
'
,
metavar
=
'
<strategy>
'
,
help
=
'
The benchmarking search strategy. Can be set to default, linear-search or binary-search
'
)
parser
.
add_argument
(
'
--reset
'
,
action
=
"
store_true
"
,
help
=
'
Resets the environment before execution
'
)
parser
.
add_argument
(
'
--reset-only
'
,
action
=
"
store_true
"
,
help
=
'
Only resets the environment. Ignores all other parameters
'
)
args
=
parser
.
parse_args
()
print
(
args
)
return
args
def
main
(
uc
,
loads
,
instances_list
,
partitions
,
cpu_limit
,
memory_limit
,
commit_ms
,
duration
,
domain_restriction
,
search_strategy
,
reset
,
reset_only
):
print
(
f
"
Domain restriction of search space activated:
{
domain_restriction
}
"
)
print
(
f
"
Domain restriction of search space activated:
{
domain_restriction
}
"
)
print
(
f
"
Chosen search strategy:
{
search_strategy
}
"
)
print
(
f
"
Chosen search strategy:
{
search_strategy
}
"
)
...
@@ -46,17 +94,17 @@ def main():
...
@@ -46,17 +94,17 @@ def main():
if
domain_restriction
:
if
domain_restriction
:
# domain restriction + linear-search
# domain restriction + linear-search
if
search_strategy
==
"
linear-search
"
:
if
search_strategy
==
"
linear-search
"
:
print
(
f
"
Going to execute at most
{
len
(
dim_values
)
+
len
(
replicas
)
-
1
}
subexperiments in total..
"
)
print
(
f
"
Going to execute at most
{
len
(
loads
)
+
len
(
instances_list
)
-
1
}
subexperiments in total..
"
)
experiment_config
=
ExperimentConfig
(
experiment_config
=
ExperimentConfig
(
use_case
=
uc
,
use_case
=
uc
,
exp_id
=
exp_id
,
exp_id
=
exp_id
,
dim_values
=
dim_value
s
,
dim_values
=
load
s
,
replicass
=
replicas
,
replicass
=
instances_list
,
partitions
=
partitions
,
partitions
=
partitions
,
cpu_limit
=
cpu_limit
,
cpu_limit
=
cpu_limit
,
memory_limit
=
memory_limit
,
memory_limit
=
memory_limit
,
kafka_streams_commit_interval_ms
=
kafka_streams_commit_interval
_ms
,
kafka_streams_commit_interval_ms
=
commit
_ms
,
execution_minutes
=
execution_minutes
,
execution_minutes
=
duration
,
domain_restriction_strategy
=
lower_bound_strategy
,
domain_restriction_strategy
=
lower_bound_strategy
,
search_strategy
=
linear_search_strategy
,
search_strategy
=
linear_search_strategy
,
subexperiment_executor
=
subexperiment_executor
,
subexperiment_executor
=
subexperiment_executor
,
...
@@ -66,30 +114,30 @@ def main():
...
@@ -66,30 +114,30 @@ def main():
experiment_config
=
ExperimentConfig
(
experiment_config
=
ExperimentConfig
(
use_case
=
uc
,
use_case
=
uc
,
exp_id
=
exp_id
,
exp_id
=
exp_id
,
dim_values
=
dim_value
s
,
dim_values
=
load
s
,
replicass
=
replicas
,
replicass
=
instances_list
,
partitions
=
partitions
,
partitions
=
partitions
,
cpu_limit
=
cpu_limit
,
cpu_limit
=
cpu_limit
,
memory_limit
=
memory_limit
,
memory_limit
=
memory_limit
,
kafka_streams_commit_interval_ms
=
kafka_streams_commit_interval
_ms
,
kafka_streams_commit_interval_ms
=
commit
_ms
,
execution_minutes
=
execution_minutes
,
execution_minutes
=
duration
,
domain_restriction_strategy
=
lower_bound_strategy
,
domain_restriction_strategy
=
lower_bound_strategy
,
search_strategy
=
binary_search_strategy
,
search_strategy
=
binary_search_strategy
,
subexperiment_executor
=
subexperiment_executor
,
subexperiment_executor
=
subexperiment_executor
,
subexperiment_evaluator
=
subexperiment_evaluator
)
subexperiment_evaluator
=
subexperiment_evaluator
)
# domain restriction + check_all
# domain restriction + check_all
else
:
else
:
print
(
f
"
Going to execute
{
len
(
dim_values
)
*
len
(
replicas
)
}
subexperiments in total..
"
)
print
(
f
"
Going to execute
{
len
(
loads
)
*
len
(
instances_list
)
}
subexperiments in total..
"
)
experiment_config
=
ExperimentConfig
(
experiment_config
=
ExperimentConfig
(
use_case
=
uc
,
use_case
=
uc
,
exp_id
=
exp_id
,
exp_id
=
exp_id
,
dim_values
=
dim_value
s
,
dim_values
=
load
s
,
replicass
=
replicas
,
replicass
=
instances_list
,
partitions
=
partitions
,
partitions
=
partitions
,
cpu_limit
=
cpu_limit
,
cpu_limit
=
cpu_limit
,
memory_limit
=
memory_limit
,
memory_limit
=
memory_limit
,
kafka_streams_commit_interval_ms
=
kafka_streams_commit_interval
_ms
,
kafka_streams_commit_interval_ms
=
commit
_ms
,
execution_minutes
=
execution_minutes
,
execution_minutes
=
duration
,
domain_restriction_strategy
=
lower_bound_strategy
,
domain_restriction_strategy
=
lower_bound_strategy
,
search_strategy
=
check_all_strategy
,
search_strategy
=
check_all_strategy
,
subexperiment_executor
=
subexperiment_executor
,
subexperiment_executor
=
subexperiment_executor
,
...
@@ -98,17 +146,17 @@ def main():
...
@@ -98,17 +146,17 @@ def main():
else
:
else
:
# no domain restriction + linear-search
# no domain restriction + linear-search
if
search_strategy
==
"
linear-search
"
:
if
search_strategy
==
"
linear-search
"
:
print
(
f
"
Going to execute at most
{
len
(
dim_values
)
*
len
(
replicas
)
}
subexperiments in total..
"
)
print
(
f
"
Going to execute at most
{
len
(
loads
)
*
len
(
instances_list
)
}
subexperiments in total..
"
)
experiment_config
=
ExperimentConfig
(
experiment_config
=
ExperimentConfig
(
use_case
=
uc
,
use_case
=
uc
,
exp_id
=
exp_id
,
exp_id
=
exp_id
,
dim_values
=
dim_value
s
,
dim_values
=
load
s
,
replicass
=
replicas
,
replicass
=
instances_list
,
partitions
=
partitions
,
partitions
=
partitions
,
cpu_limit
=
cpu_limit
,
cpu_limit
=
cpu_limit
,
memory_limit
=
memory_limit
,
memory_limit
=
memory_limit
,
kafka_streams_commit_interval_ms
=
kafka_streams_commit_interval
_ms
,
kafka_streams_commit_interval_ms
=
commit
_ms
,
execution_minutes
=
execution_minutes
,
execution_minutes
=
duration
,
domain_restriction_strategy
=
no_lower_bound_strategy
,
domain_restriction_strategy
=
no_lower_bound_strategy
,
search_strategy
=
linear_search_strategy
,
search_strategy
=
linear_search_strategy
,
subexperiment_executor
=
subexperiment_executor
,
subexperiment_executor
=
subexperiment_executor
,
...
@@ -118,30 +166,30 @@ def main():
...
@@ -118,30 +166,30 @@ def main():
experiment_config
=
ExperimentConfig
(
experiment_config
=
ExperimentConfig
(
use_case
=
uc
,
use_case
=
uc
,
exp_id
=
exp_id
,
exp_id
=
exp_id
,
dim_values
=
dim_value
s
,
dim_values
=
load
s
,
replicass
=
replicas
,
replicass
=
instances_list
,
partitions
=
partitions
,
partitions
=
partitions
,
cpu_limit
=
cpu_limit
,
cpu_limit
=
cpu_limit
,
memory_limit
=
memory_limit
,
memory_limit
=
memory_limit
,
kafka_streams_commit_interval_ms
=
kafka_streams_commit_interval
_ms
,
kafka_streams_commit_interval_ms
=
commit
_ms
,
execution_minutes
=
execution_minutes
,
execution_minutes
=
duration
,
domain_restriction_strategy
=
no_lower_bound_strategy
,
domain_restriction_strategy
=
no_lower_bound_strategy
,
search_strategy
=
binary_search_strategy
,
search_strategy
=
binary_search_strategy
,
subexperiment_executor
=
subexperiment_executor
,
subexperiment_executor
=
subexperiment_executor
,
subexperiment_evaluator
=
subexperiment_evaluator
)
subexperiment_evaluator
=
subexperiment_evaluator
)
# no domain restriction + check_all
# no domain restriction + check_all
else
:
else
:
print
(
f
"
Going to execute
{
len
(
dim_values
)
*
len
(
replicas
)
}
subexperiments in total..
"
)
print
(
f
"
Going to execute
{
len
(
loads
)
*
len
(
instances_list
)
}
subexperiments in total..
"
)
experiment_config
=
ExperimentConfig
(
experiment_config
=
ExperimentConfig
(
use_case
=
uc
,
use_case
=
uc
,
exp_id
=
exp_id
,
exp_id
=
exp_id
,
dim_values
=
dim_value
s
,
dim_values
=
load
s
,
replicass
=
replicas
,
replicass
=
instances_list
,
partitions
=
partitions
,
partitions
=
partitions
,
cpu_limit
=
cpu_limit
,
cpu_limit
=
cpu_limit
,
memory_limit
=
memory_limit
,
memory_limit
=
memory_limit
,
kafka_streams_commit_interval_ms
=
kafka_streams_commit_interval
_ms
,
kafka_streams_commit_interval_ms
=
commit
_ms
,
execution_minutes
=
execution_minutes
,
execution_minutes
=
duration
,
domain_restriction_strategy
=
no_lower_bound_strategy
,
domain_restriction_strategy
=
no_lower_bound_strategy
,
search_strategy
=
check_all_strategy
,
search_strategy
=
check_all_strategy
,
subexperiment_executor
=
subexperiment_executor
,
subexperiment_executor
=
subexperiment_executor
,
...
@@ -153,4 +201,8 @@ def main():
...
@@ -153,4 +201,8 @@ def main():
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
logging
.
basicConfig
(
level
=
logging
.
INFO
)
logging
.
basicConfig
(
level
=
logging
.
INFO
)
main
()
args
=
load_variables
()
main
(
args
.
uc
,
args
.
loads
,
args
.
instances_list
,
args
.
partitions
,
args
.
cpu_limit
,
args
.
memory_limit
,
args
.
commit_ms
,
args
.
duration
,
args
.
domain_restriction
,
args
.
search_strategy
,
args
.
reset
,
args
.
reset_only
)
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