diff --git a/execution/run_uc.py b/execution/run_uc.py index fa25f4d86a47b5e0a2a88868a2161413cb4d7b9d..8c51fbaff45210eae01e78b39dadc694e37c8bd8 100644 --- a/execution/run_uc.py +++ b/execution/run_uc.py @@ -5,6 +5,7 @@ from kubernetes.stream import stream import lag_analysis import logging # logging from os import path # path utilities +from strategies.cli_parser import execution_parser import subprocess # execute bash commands import sys # for exit of program import time # process sleep @@ -17,69 +18,8 @@ customApi = None # acces kubernetes custom object api def load_variables(): """Load the CLI variables given at the command line""" - global args print('Load CLI variables') - parser = argparse.ArgumentParser(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') - + parser = execution_parser(description='Run use case Programm') args = parser.parse_args() print(args) return args @@ -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. """ 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 @@ -590,7 +530,7 @@ if __name__ == '__main__': logging.basicConfig(level=logging.INFO) args = load_variables() 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.commit_interval_ms, args.execution_minutes, args.reset, + args.commit_ms, args.duration, args.reset, args.reset_only) diff --git a/execution/strategies/cli_parser.py b/execution/strategies/cli_parser.py index fc9698c807889fcbdbc3cff8912ff299720489a4..0b16b6ba5b5c569ed48b319ce068cf0c169c19c8 100644 --- a/execution/strategies/cli_parser.py +++ b/execution/strategies/cli_parser.py @@ -6,9 +6,9 @@ def default_parser(description): :param description: The description the argument parser should show. """ parser = argparse.ArgumentParser(description=description) - parser.add_argument('uc', + parser.add_argument('--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', default=40, type=int, @@ -44,21 +44,21 @@ def default_parser(description): def benchmark_parser(description): """ Parser for the overall benchmark execution + :param description: The description the argument parser should show. """ parser = default_parser(description) - parser.add_argument('loads', + parser.add_argument('--loads', type=int, metavar='<load>', nargs='+', - help='Loads that should be executed') + help='[mandatory] Loads that should be executed') parser.add_argument('--instances', '-i', dest='instances_list', - default=[1], type=int, - metavar='<instance>', + metavar='<instances>', nargs='+', - help='List of instances used in benchmarks') + help='[mandatory] List of instances used in benchmarks') parser.add_argument('--domain-restriction', action="store_true", help='To use domain restriction. For details see README') @@ -67,3 +67,22 @@ def benchmark_parser(description): metavar='<strategy>', help='The benchmarking search strategy. Can be set to default, linear-search or binary-search') 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 diff --git a/execution/theodolite.py b/execution/theodolite.py index 2cb522ca9e9bf3194a07f46483ce85d80f7ec38d..2cf00bbb707daff4e5654b73b6a2752931925b28 100755 --- a/execution/theodolite.py +++ b/execution/theodolite.py @@ -5,7 +5,7 @@ import logging # logging import os import sys 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.no_lower_bound_strategy as no_lower_bound_strategy import strategies.strategies.search.check_all_strategy as check_all_strategy @@ -19,7 +19,7 @@ import strategies.subexperiment_evaluation.subexperiment_evaluator as subexperim def load_variables(): """Load the CLI variables given at the command line""" print('Load CLI variables') - parser = cli_parser.benchmark_parser("Run theodolite benchmarking") + parser = benchmark_parser("Run theodolite benchmarking") args = parser.parse_args() print(args) return args