random->lhs when lacking data for GPR; fix editing session
This commit is contained in:
parent
ae98fdcb32
commit
c33625ca17
|
@ -663,6 +663,10 @@ def _http_content_to_json(content):
|
||||||
return json_content, decoded
|
return json_content, decoded
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_bool(val):
|
||||||
|
return str(val).lower() == 'true'
|
||||||
|
|
||||||
|
|
||||||
def _modify_website_object(obj_name, action, verbose=False, **kwargs):
|
def _modify_website_object(obj_name, action, verbose=False, **kwargs):
|
||||||
verbose = _parse_bool(verbose)
|
verbose = _parse_bool(verbose)
|
||||||
if obj_name == 'project':
|
if obj_name == 'project':
|
||||||
|
@ -685,11 +689,11 @@ def _modify_website_object(obj_name, action, verbose=False, **kwargs):
|
||||||
data[k] = v
|
data[k] = v
|
||||||
|
|
||||||
url_path = '/{}/{}/'.format(action, obj_name)
|
url_path = '/{}/{}/'.format(action, obj_name)
|
||||||
response = requests.post(CONF['upload_url'] + url_path, data=data)
|
response = requests.post(dconf.WEBSITE_URL + url_path, data=data)
|
||||||
|
|
||||||
content = response.content.decode('utf-8')
|
content = response.content.decode('utf-8')
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
raise Exception("Failed to {} new {}.\nStatus: {}\nMessage: {}\n".format(
|
raise Exception("Failed to {} {}.\nStatus: {}\nMessage: {}\n".format(
|
||||||
action, obj_name, response.status_code, content))
|
action, obj_name, response.status_code, content))
|
||||||
|
|
||||||
json_content, decoded = _http_content_to_json(content)
|
json_content, decoded = _http_content_to_json(content)
|
||||||
|
|
|
@ -168,11 +168,14 @@ def aggregate_target_results(result_id, algorithm):
|
||||||
# implement a sampling technique to generate new training data).
|
# implement a sampling technique to generate new training data).
|
||||||
newest_result = Result.objects.get(pk=result_id)
|
newest_result = Result.objects.get(pk=result_id)
|
||||||
has_pipeline_data = PipelineData.objects.filter(workload=newest_result.workload).exists()
|
has_pipeline_data = PipelineData.objects.filter(workload=newest_result.workload).exists()
|
||||||
if newest_result.session.tuning_session == 'lhs':
|
if not has_pipeline_data or newest_result.session.tuning_session == 'lhs':
|
||||||
|
if not has_pipeline_data and newest_result.session.tuning_session == 'tuning_session':
|
||||||
|
LOG.debug("Background tasks haven't ran for this workload yet, picking random data.")
|
||||||
|
|
||||||
all_samples = JSONUtil.loads(newest_result.session.lhs_samples)
|
all_samples = JSONUtil.loads(newest_result.session.lhs_samples)
|
||||||
if len(all_samples) == 0:
|
if len(all_samples) == 0:
|
||||||
knobs = SessionKnob.objects.get_knobs_for_session(newest_result.session)
|
knobs = SessionKnob.objects.get_knobs_for_session(newest_result.session)
|
||||||
all_samples = gen_lhs_samples(knobs, 100)
|
all_samples = gen_lhs_samples(knobs, 10)
|
||||||
LOG.debug('%s: Generated LHS.\n\ndata=%s\n',
|
LOG.debug('%s: Generated LHS.\n\ndata=%s\n',
|
||||||
AlgorithmType.name(algorithm), JSONUtil.dumps(all_samples[:5], pprint=True))
|
AlgorithmType.name(algorithm), JSONUtil.dumps(all_samples[:5], pprint=True))
|
||||||
samples = all_samples.pop()
|
samples = all_samples.pop()
|
||||||
|
@ -186,10 +189,7 @@ def aggregate_target_results(result_id, algorithm):
|
||||||
LOG.debug('%s: Got LHS config.\n\ndata=%s\n',
|
LOG.debug('%s: Got LHS config.\n\ndata=%s\n',
|
||||||
AlgorithmType.name(algorithm), JSONUtil.dumps(agg_data, pprint=True))
|
AlgorithmType.name(algorithm), JSONUtil.dumps(agg_data, pprint=True))
|
||||||
|
|
||||||
elif not has_pipeline_data or newest_result.session.tuning_session == 'randomly_generate':
|
elif newest_result.session.tuning_session == 'randomly_generate':
|
||||||
if not has_pipeline_data and newest_result.session.tuning_session == 'tuning_session':
|
|
||||||
LOG.debug("Background tasks haven't ran for this workload yet, picking random data.")
|
|
||||||
|
|
||||||
result = Result.objects.filter(pk=result_id)
|
result = Result.objects.filter(pk=result_id)
|
||||||
knobs = SessionKnob.objects.get_knobs_for_session(newest_result.session)
|
knobs = SessionKnob.objects.get_knobs_for_session(newest_result.session)
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ def configuration_recommendation(recommendation_input):
|
||||||
if target_data['bad'] is True:
|
if target_data['bad'] is True:
|
||||||
target_data_res = create_and_save_recommendation(
|
target_data_res = create_and_save_recommendation(
|
||||||
recommended_knobs=target_data['config_recommend'], result=newest_result,
|
recommended_knobs=target_data['config_recommend'], result=newest_result,
|
||||||
status='bad', info='WARNING: no training data, the config is generated randomly',
|
status='bad', info='WARNING: no training data, the config is generated by LHS',
|
||||||
pipeline_run=target_data['pipeline_run'])
|
pipeline_run=target_data['pipeline_run'])
|
||||||
LOG.debug('%s: Skipping configuration recommendation.\nData:\n%s\n\n',
|
LOG.debug('%s: Skipping configuration recommendation.\nData:\n%s\n\n',
|
||||||
AlgorithmType.name(algorithm), target_data)
|
AlgorithmType.name(algorithm), target_data)
|
||||||
|
|
|
@ -499,7 +499,7 @@ def model_to_dict2(m, exclude=None):
|
||||||
|
|
||||||
def check_and_run_celery():
|
def check_and_run_celery():
|
||||||
celery_status = os.popen('python3 manage.py celery inspect ping').read()
|
celery_status = os.popen('python3 manage.py celery inspect ping').read()
|
||||||
if 'OK' in celery_status:
|
if 'pong' in celery_status:
|
||||||
return 'celery is running'
|
return 'celery is running'
|
||||||
|
|
||||||
retries = 0
|
retries = 0
|
||||||
|
@ -510,7 +510,7 @@ def check_and_run_celery():
|
||||||
os.popen('python3 manage.py startcelery &')
|
os.popen('python3 manage.py startcelery &')
|
||||||
time.sleep(30 * retries)
|
time.sleep(30 * retries)
|
||||||
celery_status = os.popen('python3 manage.py celery inspect ping').read()
|
celery_status = os.popen('python3 manage.py celery inspect ping').read()
|
||||||
if 'OK' in celery_status:
|
if 'pong' in celery_status:
|
||||||
LOG.info('Successfully start celery.')
|
LOG.info('Successfully start celery.')
|
||||||
return 'celery stopped but is restarted successfully'
|
return 'celery stopped but is restarted successfully'
|
||||||
LOG.warning('Cannot restart celery.')
|
LOG.warning('Cannot restart celery.')
|
||||||
|
|
Loading…
Reference in New Issue