random->lhs when lacking data for GPR; fix editing session

This commit is contained in:
yangdsh
2020-02-03 20:59:23 +00:00
committed by Dana Van Aken
parent ae98fdcb32
commit c33625ca17
3 changed files with 15 additions and 11 deletions

View File

@@ -168,11 +168,14 @@ def aggregate_target_results(result_id, algorithm):
# implement a sampling technique to generate new training data).
newest_result = Result.objects.get(pk=result_id)
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)
if len(all_samples) == 0:
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',
AlgorithmType.name(algorithm), JSONUtil.dumps(all_samples[:5], pprint=True))
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',
AlgorithmType.name(algorithm), JSONUtil.dumps(agg_data, pprint=True))
elif not has_pipeline_data or 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.")
elif newest_result.session.tuning_session == 'randomly_generate':
result = Result.objects.filter(pk=result_id)
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:
target_data_res = create_and_save_recommendation(
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'])
LOG.debug('%s: Skipping configuration recommendation.\nData:\n%s\n\n',
AlgorithmType.name(algorithm), target_data)

View File

@@ -499,7 +499,7 @@ def model_to_dict2(m, exclude=None):
def check_and_run_celery():
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'
retries = 0
@@ -510,7 +510,7 @@ def check_and_run_celery():
os.popen('python3 manage.py startcelery &')
time.sleep(30 * retries)
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.')
return 'celery stopped but is restarted successfully'
LOG.warning('Cannot restart celery.')