diff --git a/execution/lib/cli_parser.py b/execution/lib/cli_parser.py index f785bce4f933622a99b4daaadeb483276d4956cd..218999b173306a32237b2657b32bdea061d3d4e0 100644 --- a/execution/lib/cli_parser.py +++ b/execution/lib/cli_parser.py @@ -10,6 +10,36 @@ def env_list_default(env, tf): v = [tf(s) for s in v.split(',')] return v + +def key_values_to_dict(kvs): + """ + Given a list with key values in form `Key=Value` it creates a dict from it. + """ + my_dict = {} + for kv in kvs: + k,v = kv.split("=") + my_dict[k] = v + return my_dict + + +def env_dict_default(env): + """ + Makes a dict from an environment string. + """ + v = os.environ.get(env) + if v is not None: + return key_values_to_dict(v.split(',')) + + +class StoreDictKeyPair(argparse.Action): + def __init__(self, option_strings, dest, nargs=None, **kwargs): + self._nargs = nargs + super(StoreDictKeyPair, self).__init__(option_strings, dest, nargs=nargs, **kwargs) + def __call__(self, parser, namespace, values, option_string=None): + my_dict = key_values_to_dict(values) + setattr(namespace, self.dest, my_dict) + + def default_parser(description): """ Returns the default parser that can be used for thodolite and run uc py @@ -62,6 +92,12 @@ def default_parser(description): metavar='<path>', default=os.environ.get('RESULT_PATH', 'results'), help='A directory path for the results') + parser.add_argument("--configurations", + dest="configurations", + action=StoreDictKeyPair, + nargs="+", + default=env_dict_default('CONFIGURATIONS'), + metavar="KEY=VAL") return parser def benchmark_parser(description): diff --git a/execution/theodolite.yaml b/execution/theodolite.yaml index 1c1ba6a1f3d9119dddd4668c27e1b1a10291895e..9ea35ebf9fb051c95dd36d9d759c6b14a4de16da 100644 --- a/execution/theodolite.yaml +++ b/execution/theodolite.yaml @@ -36,6 +36,8 @@ spec: value: "http://prometheus-operated:9090" # - name: NAMESPACE # value: "default" + # - name: CONFIGURATIONS + # value: "COMMIT_INTERVAL_MS=100, NUM_STREAM_THREADS=1" - name: RESULT_PATH value: "results" - name: PYTHONUNBUFFERED