Skip to content
Snippets Groups Projects
Commit 909f4e96 authored by Björn Vonheiden's avatar Björn Vonheiden
Browse files

Use common parser in run uc and make all cli arguments optional

parent 8d116803
No related branches found
No related tags found
1 merge request!44Enhanced CLI arguments for theodolite
...@@ -5,6 +5,7 @@ from kubernetes.stream import stream ...@@ -5,6 +5,7 @@ from kubernetes.stream import stream
import lag_analysis import lag_analysis
import logging # logging import logging # logging
from os import path # path utilities from os import path # path utilities
from strategies.cli_parser import execution_parser
import subprocess # execute bash commands import subprocess # execute bash commands
import sys # for exit of program import sys # for exit of program
import time # process sleep import time # process sleep
...@@ -17,69 +18,8 @@ customApi = None # acces kubernetes custom object api ...@@ -17,69 +18,8 @@ customApi = None # acces kubernetes custom object api
def load_variables(): def load_variables():
"""Load the CLI variables given at the command line""" """Load the CLI variables given at the command line"""
global args
print('Load CLI variables') print('Load CLI variables')
parser = argparse.ArgumentParser(description='Run use case Programm') parser = execution_parser(description='Run use case Programm')
parser.add_argument('--exp-id', '-id',
dest='exp_id',
default='1',
metavar='EXP_ID',
help='ID of the experiment')
parser.add_argument('--use-case', '-uc',
dest='uc_id',
default='1',
metavar='UC_NUMBER',
help='use case number, one of 1, 2, 3 or 4')
parser.add_argument('--dim-value', '-d',
dest='dim_value',
default=10000,
type=int,
metavar='DIM_VALUE',
help='Value for the workload generator to be tested')
parser.add_argument('--instances', '-i',
dest='instances',
default=1,
type=int,
metavar='INSTANCES',
help='Numbers of instances to be benchmarked')
parser.add_argument('--partitions', '-p',
dest='partitions',
default=40,
type=int,
metavar='PARTITIONS',
help='Number of partitions for Kafka topics')
parser.add_argument('--cpu-limit', '-cpu',
dest='cpu_limit',
default='1000m',
metavar='CPU_LIMIT',
help='Kubernetes CPU limit')
parser.add_argument('--memory-limit', '-mem',
dest='memory_limit',
default='4Gi',
metavar='MEMORY_LIMIT',
help='Kubernetes memory limit')
parser.add_argument('--commit-interval', '-ci',
dest='commit_interval_ms',
default=100,
type=int,
metavar='KAFKA_STREAMS_COMMIT_INTERVAL_MS',
help='Kafka Streams commit interval in milliseconds')
parser.add_argument('--executions-minutes', '-exm',
dest='execution_minutes',
default=5,
type=int,
metavar='EXECUTION_MINUTES',
help='Duration in minutes subexperiments should be \
executed for')
parser.add_argument('--reset', '-res',
dest='reset',
action="store_true",
help='Resets the environment before execution')
parser.add_argument('--reset-only', '-reso',
dest='reset_only',
action="store_true",
help='Only resets the environment. Ignores all other parameters')
args = parser.parse_args() args = parser.parse_args()
print(args) print(args)
return args return args
...@@ -310,7 +250,7 @@ def run_evaluation(exp_id, uc_id, dim_value, instances, execution_minutes): ...@@ -310,7 +250,7 @@ def run_evaluation(exp_id, uc_id, dim_value, instances, execution_minutes):
:param int execution_minutes: How long the use case where executed. :param int execution_minutes: How long the use case where executed.
""" """
print('Run evaluation function') print('Run evaluation function')
lag_analysis.main(exp_id, f'uc{uc_id}', dim_value, instances, execution_minutes) lag_analysis.main(exp_id, f'uc{uc_id}', dim_value, instances, execution_minutes, 'http://localhost:9090')
return return
...@@ -590,7 +530,7 @@ if __name__ == '__main__': ...@@ -590,7 +530,7 @@ if __name__ == '__main__':
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
args = load_variables() args = load_variables()
print('---------------------') print('---------------------')
main(args.exp_id, args.uc_id, args.dim_value, args.instances, main(args.exp_id, args.uc, args.load, args.instances,
args.partitions, args.cpu_limit, args.memory_limit, args.partitions, args.cpu_limit, args.memory_limit,
args.commit_interval_ms, args.execution_minutes, args.reset, args.commit_ms, args.duration, args.reset,
args.reset_only) args.reset_only)
...@@ -6,9 +6,9 @@ def default_parser(description): ...@@ -6,9 +6,9 @@ def default_parser(description):
:param description: The description the argument parser should show. :param description: The description the argument parser should show.
""" """
parser = argparse.ArgumentParser(description=description) parser = argparse.ArgumentParser(description=description)
parser.add_argument('uc', parser.add_argument('--uc',
metavar='<uc>', metavar='<uc>',
help='use case number, one of 1, 2, 3 or 4') help='[mandatory] use case number, one of 1, 2, 3 or 4')
parser.add_argument('--partitions', '-p', parser.add_argument('--partitions', '-p',
default=40, default=40,
type=int, type=int,
...@@ -44,21 +44,21 @@ def default_parser(description): ...@@ -44,21 +44,21 @@ def default_parser(description):
def benchmark_parser(description): def benchmark_parser(description):
""" """
Parser for the overall benchmark execution Parser for the overall benchmark execution
:param description: The description the argument parser should show.
""" """
parser = default_parser(description) parser = default_parser(description)
parser.add_argument('loads', parser.add_argument('--loads',
type=int, type=int,
metavar='<load>', metavar='<load>',
nargs='+', nargs='+',
help='Loads that should be executed') help='[mandatory] Loads that should be executed')
parser.add_argument('--instances', '-i', parser.add_argument('--instances', '-i',
dest='instances_list', dest='instances_list',
default=[1],
type=int, type=int,
metavar='<instance>', metavar='<instances>',
nargs='+', nargs='+',
help='List of instances used in benchmarks') help='[mandatory] List of instances used in benchmarks')
parser.add_argument('--domain-restriction', parser.add_argument('--domain-restriction',
action="store_true", action="store_true",
help='To use domain restriction. For details see README') help='To use domain restriction. For details see README')
...@@ -67,3 +67,22 @@ def benchmark_parser(description): ...@@ -67,3 +67,22 @@ def benchmark_parser(description):
metavar='<strategy>', metavar='<strategy>',
help='The benchmarking search strategy. Can be set to default, linear-search or binary-search') help='The benchmarking search strategy. Can be set to default, linear-search or binary-search')
return parser return parser
def execution_parser(description):
"""
Parser for executing one use case
:param description: The description the argument parser should show.
"""
parser = default_parser(description)
parser.add_argument('--exp-id',
metavar='<exp id>',
help='[mandatory] ID of the experiment')
parser.add_argument('--load',
type=int,
metavar='<load>',
help='[mandatory] Load that should be used for benchmakr')
parser.add_argument('--instances',
type=int,
metavar='<instances>',
help='[mandatory] Numbers of instances to be benchmarked')
return parser
...@@ -5,7 +5,7 @@ import logging # logging ...@@ -5,7 +5,7 @@ import logging # logging
import os import os
import sys import sys
from strategies.config import ExperimentConfig from strategies.config import ExperimentConfig
import strategies.cli_parser as cli_parser from strategies.cli_parser import benchmark_parser
import strategies.strategies.domain_restriction.lower_bound_strategy as lower_bound_strategy import strategies.strategies.domain_restriction.lower_bound_strategy as lower_bound_strategy
import strategies.strategies.domain_restriction.no_lower_bound_strategy as no_lower_bound_strategy import strategies.strategies.domain_restriction.no_lower_bound_strategy as no_lower_bound_strategy
import strategies.strategies.search.check_all_strategy as check_all_strategy import strategies.strategies.search.check_all_strategy as check_all_strategy
...@@ -19,7 +19,7 @@ import strategies.subexperiment_evaluation.subexperiment_evaluator as subexperim ...@@ -19,7 +19,7 @@ import strategies.subexperiment_evaluation.subexperiment_evaluator as subexperim
def load_variables(): def load_variables():
"""Load the CLI variables given at the command line""" """Load the CLI variables given at the command line"""
print('Load CLI variables') print('Load CLI variables')
parser = cli_parser.benchmark_parser("Run theodolite benchmarking") parser = benchmark_parser("Run theodolite benchmarking")
args = parser.parse_args() args = parser.parse_args()
print(args) print(args)
return args return args
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment