Added target objective to comparison

This commit is contained in:
arifiorino 2019-12-21 04:24:33 +00:00 committed by Dana Van Aken
parent e55aef5483
commit d007d932b5
2 changed files with 21 additions and 7 deletions

View File

@ -41,9 +41,9 @@
<caption></caption> <caption></caption>
<tr> <tr>
<td><h5><strong>Name</strong><h5></td> <td><h5><strong>Name</strong><h5></td>
<td><h5><strong>Value</strong></h5></td> <td><h5><strong>Value {{ target_obj }}</strong></h5></td>
{% if compare != "none" %} {% if compare != "none" %}
<td><h5><strong>Comparing Value</strong></h5></td> <td><h5><strong>Comparing Value {{ cmp_target_obj }}</strong></h5></td>
{% endif %} {% endif %}
</tr> </tr>
{% for pair in featured_data %} {% for pair in featured_data %}

View File

@ -708,8 +708,10 @@ def knob_data_view(request, project_id, session_id, data_id): # pylint: disable
'labels': labels, 'labels': labels,
'data_type': 'knobs' 'data_type': 'knobs'
} }
return dbms_data_view(request, context, knob_data) result = Result.objects.filter(knob_data=knob_data)[0]
session = get_object_or_404(Session, pk=session_id)
target_obj = JSONUtil.loads(result.metric_data.data)[session.target_objective]
return dbms_data_view(request, context, knob_data, session, target_obj)
@login_required(login_url=reverse_lazy('login')) @login_required(login_url=reverse_lazy('login'))
def metric_data_view(request, project_id, session_id, data_id): # pylint: disable=unused-argument def metric_data_view(request, project_id, session_id, data_id): # pylint: disable=unused-argument
@ -724,10 +726,12 @@ def metric_data_view(request, project_id, session_id, data_id): # pylint: disab
'labels': labels, 'labels': labels,
'data_type': 'metrics' 'data_type': 'metrics'
} }
return dbms_data_view(request, context, metric_data) result = Result.objects.filter(metric_data=metric_data)[0]
session = get_object_or_404(Session, pk=session_id)
target_obj = JSONUtil.loads(result.metric_data.data)[session.target_objective]
return dbms_data_view(request, context, metric_data, session, target_obj)
def dbms_data_view(request, context, dbms_data, session, target_obj):
def dbms_data_view(request, context, dbms_data):
if context['data_type'] == 'knobs': if context['data_type'] == 'knobs':
model_class = KnobData model_class = KnobData
filter_fn = parser.filter_tunable_knobs filter_fn = parser.filter_tunable_knobs
@ -741,6 +745,9 @@ def dbms_data_view(request, context, dbms_data):
all_data_dict = JSONUtil.loads(obj_data) all_data_dict = JSONUtil.loads(obj_data)
featured_dict = filter_fn(dbms_id, all_data_dict) featured_dict = filter_fn(dbms_id, all_data_dict)
target_obj_name = target_objectives.get_instance(
session.dbms.pk, session.target_objective).pprint
target_obj = '('+target_obj_name+'='+str(int(target_obj))+')'
if 'compare' in request.GET and request.GET['compare'] != 'none': if 'compare' in request.GET and request.GET['compare'] != 'none':
comp_id = request.GET['compare'] comp_id = request.GET['compare']
compare_obj = model_class.objects.get(pk=comp_id) compare_obj = model_class.objects.get(pk=comp_id)
@ -752,10 +759,15 @@ def dbms_data_view(request, context, dbms_data):
all_data = [(k, v, comp_dict[k]) for k, v in list(all_data_dict.items())] all_data = [(k, v, comp_dict[k]) for k, v in list(all_data_dict.items())]
featured_data = [(k, v, comp_featured_dict[k]) featured_data = [(k, v, comp_featured_dict[k])
for k, v in list(featured_dict.items())] for k, v in list(featured_dict.items())]
result = Result.objects.filter(knob_data=compare_obj)[0]
cmp_target_obj = JSONUtil.loads(result.metric_data.data)[session.target_objective]
cmp_target_obj = '('+target_obj_name+'='+str(int(cmp_target_obj))+')'
else: else:
comp_id = None comp_id = None
all_data = list(all_data_dict.items()) all_data = list(all_data_dict.items())
featured_data = list(featured_dict.items()) featured_data = list(featured_dict.items())
cmp_target_obj = ""
peer_data = model_class.objects.filter( peer_data = model_class.objects.filter(
dbms=dbms_data.dbms, session=dbms_data.session) dbms=dbms_data.dbms, session=dbms_data.session)
peer_data = [peer for peer in peer_data if peer.pk != dbms_data.pk] peer_data = [peer for peer in peer_data if peer.pk != dbms_data.pk]
@ -765,6 +777,8 @@ def dbms_data_view(request, context, dbms_data):
context['dbms_data'] = dbms_data context['dbms_data'] = dbms_data
context['compare'] = comp_id context['compare'] = comp_id
context['peer_data'] = peer_data context['peer_data'] = peer_data
context['target_obj'] = target_obj
context['cmp_target_obj'] = cmp_target_obj
return render(request, 'dbms_data.html', context) return render(request, 'dbms_data.html', context)