From 7ade03e3e55f2f05ab6f86e57112e3b5fd95f948 Mon Sep 17 00:00:00 2001 From: yangdsh Date: Tue, 10 Dec 2019 02:23:22 +0000 Subject: [PATCH] fix bugs --- client/driver/utils.py | 8 ++++---- server/website/website/tasks/async_tasks.py | 12 ++++++------ server/website/website/views.py | 12 +----------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/client/driver/utils.py b/client/driver/utils.py index 76522b3..af66ca1 100644 --- a/client/driver/utils.py +++ b/client/driver/utils.py @@ -75,7 +75,7 @@ def run(cmd, capture=True, **kwargs): if cmd.endswith('&'): cmdd = cmd[:-1].strip() opts = '-d ' - res = local('sudo docker exec {} -ti {} /bin/bash -c "{}"'.format( + res = local('docker exec {} -ti {} /bin/bash -c "{}"'.format( opts, dconf.CONTAINER_NAME, cmdd), capture=capture, **kwargs) except TypeError as e: err = str(e).strip() @@ -106,7 +106,7 @@ def sudo(cmd, user=None, capture=True, **kwargs): opts = '-ti -u {}'.format(user or 'root') if user == 'root': opts += ' -w /' - res = local('sudo docker exec {} {} /bin/bash -c "{}"'.format( + res = local('docker exec {} {} /bin/bash -c "{}"'.format( opts, dconf.CONTAINER_NAME, cmd), capture=capture) return res @@ -123,7 +123,7 @@ def get(remote_path, local_path, use_sudo=False): opts = '-r' if os.path.isdir(remote_path) else '' res = local('{}cp {} {} {}'.format(pre_cmd, opts, remote_path, local_path)) else: # docker - res = local('sudo docker cp {}:{} {}'.format(dconf.CONTAINER_NAME, remote_path, local_path)) + res = local('docker cp {}:{} {}'.format(dconf.CONTAINER_NAME, remote_path, local_path)) return res @@ -138,7 +138,7 @@ def put(local_path, remote_path, use_sudo=False): opts = '-r' if os.path.isdir(local_path) else '' res = local('{}cp {} {} {}'.format(pre_cmd, opts, local_path, remote_path)) else: # docker - res = local('sudo docker cp {} {}:{}'.format(local_path, dconf.CONTAINER_NAME, remote_path)) + res = local('docker cp {} {}:{}'.format(local_path, dconf.CONTAINER_NAME, remote_path)) return res diff --git a/server/website/website/tasks/async_tasks.py b/server/website/website/tasks/async_tasks.py index 287d1b5..fcffae9 100644 --- a/server/website/website/tasks/async_tasks.py +++ b/server/website/website/tasks/async_tasks.py @@ -110,6 +110,12 @@ class ConfigurationRecommendation(UpdateTask): # pylint: disable=abstract-metho result_id = retval['result_id'] result = Result.objects.get(pk=result_id) + # Create next configuration to try + config = db.parser.create_knob_configuration(result.dbms.pk, retval['recommendation']) + retval['recommendation'] = config + result.next_configuration = JSONUtil.dumps(retval) + result.save() + # Replace result with formatted result formatted_params = db.parser.format_dbms_knobs(result.dbms.pk, retval['recommendation']) task_meta = TaskMeta.objects.get(task_id=task_id) @@ -117,12 +123,6 @@ class ConfigurationRecommendation(UpdateTask): # pylint: disable=abstract-metho task_meta.result = retval task_meta.save() - # Create next configuration to try - config = db.parser.create_knob_configuration(result.dbms.pk, retval['recommendation']) - retval['recommendation'] = config - result.next_configuration = JSONUtil.dumps(retval) - result.save() - def clean_knob_data(knob_matrix, knob_labels, session): # Makes sure that all knobs in the dbms are included in the knob_matrix and knob_labels diff --git a/server/website/website/views.py b/server/website/website/views.py index ce12dfb..8eac683 100644 --- a/server/website/website/views.py +++ b/server/website/website/views.py @@ -491,17 +491,7 @@ def handle_result_files(session, files): for knob in data_knobs.keys(): for tunable_knob in last_conf.keys(): if tunable_knob in knob: - unit = KnobCatalog.objects.get(dbms=session.dbms, name=knob).unit - bytes_system = ConversionUtil.DEFAULT_BYTES_SYSTEM - time_system = ConversionUtil.DEFAULT_TIME_SYSTEM - if unit == 1: - data_knobs[knob] = ConversionUtil.get_raw_size(last_conf[tunable_knob], - bytes_system) - elif unit == 2: - data_knobs[knob] = ConversionUtil.get_raw_size(last_conf[tunable_knob], - time_system) - else: - data_knobs[knob] = last_conf[tunable_knob] + data_knobs[knob] = last_conf[tunable_knob] knob_data.data = JSONUtil.dumps(data_knobs) knob_data.name = knob_data.name + '*'