fix bug of finding worst result when there is no result

This commit is contained in:
yangdsh 2020-03-06 03:53:37 +00:00 committed by Dana Van Aken
parent e5e42a4ed6
commit d581703375
1 changed files with 19 additions and 18 deletions

View File

@ -487,26 +487,27 @@ def handle_result_files(session, files, execution_times=None):
# Find worst throughput # Find worst throughput
past_metrics = MetricData.objects.filter(session=session) past_metrics = MetricData.objects.filter(session=session)
metric_meta = target_objectives.get_instance(session.dbms.pk, session.target_objective) metric_meta = target_objectives.get_instance(session.dbms.pk, session.target_objective)
worst_metric = past_metrics.first() if len(past_metrics) > 0:
worst_target_value = JSONUtil.loads(worst_metric.data)[session.target_objective] worst_metric = past_metrics.first()
for past_metric in past_metrics: worst_target_value = JSONUtil.loads(worst_metric.data)[session.target_objective]
if '*' in past_metric.name: for past_metric in past_metrics:
continue if '*' in past_metric.name:
target_value = JSONUtil.loads(past_metric.data)[session.target_objective] continue
target_value = JSONUtil.loads(past_metric.data)[session.target_objective]
if metric_meta.improvement == target_objectives.MORE_IS_BETTER:
if worst_target_value is None or target_value < worst_target_value:
worst_target_value = target_value
worst_metric = past_metric
else:
if worst_target_value is None or target_value > worst_target_value:
worst_target_value = target_value
worst_metric = past_metric
LOG.debug("Worst target value so far is: %d", worst_target_value)
penalty_factor = JSONUtil.loads(session.hyperparameters).get('PENALTY_FACTOR', 2)
if metric_meta.improvement == target_objectives.MORE_IS_BETTER: if metric_meta.improvement == target_objectives.MORE_IS_BETTER:
if worst_target_value is None or target_value < worst_target_value: penalty_target_value = worst_target_value / penalty_factor
worst_target_value = target_value
worst_metric = past_metric
else: else:
if worst_target_value is None or target_value > worst_target_value: penalty_target_value = worst_target_value * penalty_factor
worst_target_value = target_value
worst_metric = past_metric
LOG.debug("Worst target value so far is: %d", worst_target_value)
penalty_factor = JSONUtil.loads(session.hyperparameters).get('PENALTY_FACTOR', 2)
if metric_meta.improvement == target_objectives.MORE_IS_BETTER:
penalty_target_value = worst_target_value / penalty_factor
else:
penalty_target_value = worst_target_value * penalty_factor
# Update the past invalid results # Update the past invalid results
for past_metric in past_metrics: for past_metric in past_metrics: