summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/views.py
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-05-26 16:12:22 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-15 08:35:04 +0100
commitb2a68f55110b39aaf0b0d47bf533251a59a40a41 (patch)
tree7791ed85141e07f01c228619047740b235ee02dc /bitbake/lib/toaster/toastergui/views.py
parent32d1e2dd25f288790450db48766cf115854712ba (diff)
downloadpoky-b2a68f55110b39aaf0b0d47bf533251a59a40a41.tar.gz
bitbake: toaster: port Task tables to ToasterTables widget
Port the Task based tables to ToasterTable. This is the Task, Time, CPU usage and Disk I/O tables. (Bitbake rev: bebcef7a4bf08b10e472475435ddc7a524364adb) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/views.py')
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py280
1 files changed, 1 insertions, 279 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index 3a25d5ea1e..35ab63a22e 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -596,6 +596,7 @@ def task( request, build_id, task_id ):
596 'log_body' : log_body, 596 'log_body' : log_body,
597 'showing_matches' : False, 597 'showing_matches' : False,
598 'uri_list' : uri_list, 598 'uri_list' : uri_list,
599 'task_in_tasks_table_pg': int(task_object.order / 25) + 1
599 } 600 }
600 if request.GET.get( 'show_matches', "" ): 601 if request.GET.get( 'show_matches', "" ):
601 context[ 'showing_matches' ] = True 602 context[ 'showing_matches' ] = True
@@ -995,285 +996,6 @@ def _find_task_provider(task_object):
995 return trc 996 return trc
996 return None 997 return None
997 998
998def tasks_common(request, build_id, variant, task_anchor):
999# This class is shared between these pages
1000#
1001# Column tasks buildtime diskio cpuusage
1002# --------- ------ ---------- ------- ---------
1003# Cache def
1004# CPU min -
1005# Disk min -
1006# Executed def def def def
1007# Log
1008# Order def +
1009# Outcome def def def def
1010# Recipe min min min min
1011# Version
1012# Task min min min min
1013# Time min -
1014#
1015# 'min':on always, 'def':on by default, else hidden
1016# '+' default column sort up, '-' default column sort down
1017
1018 anchor = request.GET.get('anchor', '')
1019 if not anchor:
1020 anchor=task_anchor
1021
1022 # default ordering depends on variant
1023 default_orderby = None
1024 filter_search_display = 'tasks'
1025
1026 if 'buildtime' == variant:
1027 default_orderby = 'elapsed_time:-'
1028 title_variant = 'Time'
1029 object_search_display = 'time data'
1030 elif 'diskio' == variant:
1031 default_orderby = 'disk_io:-'
1032 title_variant = 'Disk I/O'
1033 object_search_display = 'disk I/O data'
1034 elif 'cputime' == variant:
1035 default_orderby = 'cpu_time_system:-'
1036 title_variant='CPU time'
1037 object_search_display = 'CPU time data'
1038 else:
1039 default_orderby = 'order:+'
1040 title_variant = 'Tasks'
1041 object_search_display = 'tasks'
1042
1043 (pagesize, orderby) = _get_parameters_values(request, 25, default_orderby)
1044
1045 mandatory_parameters = {'count': pagesize, 'page' : 1, 'orderby': orderby}
1046
1047 template = 'tasks.html'
1048 retval = _verify_parameters( request.GET, mandatory_parameters )
1049 if retval:
1050 if task_anchor:
1051 mandatory_parameters['anchor']=task_anchor
1052 return _redirect_parameters( variant, request.GET, mandatory_parameters, build_id = build_id)
1053 (filter_string, search_term, ordering_string) = _search_tuple(request, Task)
1054 queryset_all = Task.objects.filter(build=build_id).exclude(order__isnull=True).exclude(outcome=Task.OUTCOME_NA)
1055 queryset_all = queryset_all.select_related("recipe", "build")
1056
1057 queryset_with_search = _get_queryset(Task, queryset_all, None , search_term, ordering_string, 'order')
1058
1059 if ordering_string.startswith('outcome'):
1060 queryset = _get_queryset(Task, queryset_all, filter_string, search_term, 'order:+', 'order')
1061 queryset = sorted(queryset, key=lambda ur: (ur.outcome_text), reverse=ordering_string.endswith('-'))
1062 elif ordering_string.startswith('sstate_result'):
1063 queryset = _get_queryset(Task, queryset_all, filter_string, search_term, 'order:+', 'order')
1064 queryset = sorted(queryset, key=lambda ur: (ur.sstate_text), reverse=ordering_string.endswith('-'))
1065 else:
1066 queryset = _get_queryset(Task, queryset_all, filter_string, search_term, ordering_string, 'order')
1067
1068
1069 # compute the anchor's page
1070 if anchor:
1071 request.GET = request.GET.copy()
1072 del request.GET['anchor']
1073 i=0
1074 a=int(anchor)
1075 count_per_page=int(pagesize)
1076 for task_object in queryset.iterator():
1077 if a == task_object.order:
1078 new_page= (i / count_per_page ) + 1
1079 request.GET.__setitem__('page', new_page)
1080 mandatory_parameters['page']=new_page
1081 return _redirect_parameters( variant, request.GET, mandatory_parameters, build_id = build_id)
1082 i += 1
1083
1084 task_objects = _build_page_range(Paginator(queryset, pagesize),request.GET.get('page', 1))
1085
1086 # define (and modify by variants) the 'tablecols' members
1087 tc_order={
1088 'name':'Order',
1089 'qhelp':'The running sequence of each task in the build',
1090 'clclass': 'order', 'hidden' : 1,
1091 'orderkey' : 'order',
1092 'orderfield':_get_toggle_order(request, "order"),
1093 'ordericon':_get_toggle_order_icon(request, "order")}
1094 if 'tasks' == variant:
1095 tc_order['hidden']='0'
1096 del tc_order['clclass']
1097
1098 tc_recipe={
1099 'name':'Recipe',
1100 'qhelp':'The name of the recipe to which each task applies',
1101 'orderkey' : 'recipe__name',
1102 'orderfield': _get_toggle_order(request, "recipe__name"),
1103 'ordericon':_get_toggle_order_icon(request, "recipe__name"),
1104 }
1105 tc_recipe_version={
1106 'name':'Recipe version',
1107 'qhelp':'The version of the recipe to which each task applies',
1108 'clclass': 'recipe_version', 'hidden' : 1,
1109 }
1110 tc_task={
1111 'name':'Task',
1112 'qhelp':'The name of the task',
1113 'orderfield': _get_toggle_order(request, "task_name"),
1114 'ordericon':_get_toggle_order_icon(request, "task_name"),
1115 'orderkey' : 'task_name',
1116 }
1117 tc_executed={
1118 'name':'Executed',
1119 'qhelp':"This value tells you if a task had to run (executed) in order to generate the task output, or if the output was provided by another task and therefore the task didn't need to run (not executed)",
1120 'clclass': 'executed', 'hidden' : 0,
1121 'orderfield': _get_toggle_order(request, "task_executed"),
1122 'ordericon':_get_toggle_order_icon(request, "task_executed"),
1123 'orderkey' : 'task_executed',
1124 'filter' : {
1125 'class' : 'executed',
1126 'label': 'Show:',
1127 'options' : [
1128 ('Executed Tasks', 'task_executed:1', queryset_with_search.filter(task_executed=1).count()),
1129 ('Not Executed Tasks', 'task_executed:0', queryset_with_search.filter(task_executed=0).count()),
1130 ]
1131 }
1132
1133 }
1134 tc_outcome={
1135 'name':'Outcome',
1136 'qhelp':"This column tells you if 'executed' tasks succeeded or failed. The column also tells you why 'not executed' tasks did not need to run",
1137 'clclass': 'outcome', 'hidden' : 0,
1138 'orderfield': _get_toggle_order(request, "outcome"),
1139 'ordericon':_get_toggle_order_icon(request, "outcome"),
1140 'orderkey' : 'outcome',
1141 'filter' : {
1142 'class' : 'outcome',
1143 'label': 'Show:',
1144 'options' : [
1145 ('Succeeded Tasks', 'outcome:%d'%Task.OUTCOME_SUCCESS, queryset_with_search.filter(outcome=Task.OUTCOME_SUCCESS).count(), "'Succeeded' tasks are those that ran and completed during the build" ),
1146 ('Failed Tasks', 'outcome:%d'%Task.OUTCOME_FAILED, queryset_with_search.filter(outcome=Task.OUTCOME_FAILED).count(), "'Failed' tasks are those that ran but did not complete during the build"),
1147 ('Cached Tasks', 'outcome:%d'%Task.OUTCOME_CACHED, queryset_with_search.filter(outcome=Task.OUTCOME_CACHED).count(), 'Cached tasks restore output from the <code>sstate-cache</code> directory or mirrors'),
1148 ('Prebuilt Tasks', 'outcome:%d'%Task.OUTCOME_PREBUILT, queryset_with_search.filter(outcome=Task.OUTCOME_PREBUILT).count(),'Prebuilt tasks didn\'t need to run because their output was reused from a previous build'),
1149 ('Covered Tasks', 'outcome:%d'%Task.OUTCOME_COVERED, queryset_with_search.filter(outcome=Task.OUTCOME_COVERED).count(), 'Covered tasks didn\'t need to run because their output is provided by another task in this build'),
1150 ('Empty Tasks', 'outcome:%d'%Task.OUTCOME_EMPTY, queryset_with_search.filter(outcome=Task.OUTCOME_EMPTY).count(), 'Empty tasks have no executable content'),
1151 ]
1152 }
1153
1154 }
1155
1156 tc_cache={
1157 'name':'Cache attempt',
1158 'qhelp':'This column tells you if a task tried to restore output from the <code>sstate-cache</code> directory or mirrors, and reports the result: Succeeded, Failed or File not in cache',
1159 'clclass': 'cache_attempt', 'hidden' : 0,
1160 'orderfield': _get_toggle_order(request, "sstate_result"),
1161 'ordericon':_get_toggle_order_icon(request, "sstate_result"),
1162 'orderkey' : 'sstate_result',
1163 'filter' : {
1164 'class' : 'cache_attempt',
1165 'label': 'Show:',
1166 'options' : [
1167 ('Tasks with cache attempts', 'sstate_result__gt:%d'%Task.SSTATE_NA, queryset_with_search.filter(sstate_result__gt=Task.SSTATE_NA).count(), 'Show all tasks that tried to restore ouput from the <code>sstate-cache</code> directory or mirrors'),
1168 ("Tasks with 'File not in cache' attempts", 'sstate_result:%d'%Task.SSTATE_MISS, queryset_with_search.filter(sstate_result=Task.SSTATE_MISS).count(), 'Show tasks that tried to restore output, but did not find it in the <code>sstate-cache</code> directory or mirrors'),
1169 ("Tasks with 'Failed' cache attempts", 'sstate_result:%d'%Task.SSTATE_FAILED, queryset_with_search.filter(sstate_result=Task.SSTATE_FAILED).count(), 'Show tasks that found the required output in the <code>sstate-cache</code> directory or mirrors, but could not restore it'),
1170 ("Tasks with 'Succeeded' cache attempts", 'sstate_result:%d'%Task.SSTATE_RESTORED, queryset_with_search.filter(sstate_result=Task.SSTATE_RESTORED).count(), 'Show tasks that successfully restored the required output from the <code>sstate-cache</code> directory or mirrors'),
1171 ]
1172 }
1173
1174 }
1175 #if 'tasks' == variant: tc_cache['hidden']='0';
1176 tc_time={
1177 'name':'Time (secs)',
1178 'qhelp':'How long it took the task to finish in seconds',
1179 'orderfield': _get_toggle_order(request, "elapsed_time", True),
1180 'ordericon':_get_toggle_order_icon(request, "elapsed_time"),
1181 'orderkey' : 'elapsed_time',
1182 'clclass': 'time_taken', 'hidden' : 1,
1183 }
1184 if 'buildtime' == variant:
1185 tc_time['hidden']='0'
1186 del tc_time['clclass']
1187 tc_cache['hidden']='1'
1188
1189 tc_cpu_time_system={
1190 'name':'System CPU time (secs)',
1191 'qhelp':'Total amount of time spent executing in kernel mode, in ' +
1192 'seconds. Note that this time can be greater than the task ' +
1193 'time due to parallel execution.',
1194 'orderfield': _get_toggle_order(request, "cpu_time_system", True),
1195 'ordericon':_get_toggle_order_icon(request, "cpu_time_system"),
1196 'orderkey' : 'cpu_time_system',
1197 'clclass': 'cpu_time_system', 'hidden' : 1,
1198 }
1199
1200 tc_cpu_time_user={
1201 'name':'User CPU time (secs)',
1202 'qhelp':'Total amount of time spent executing in user mode, in seconds. ' +
1203 'Note that this time can be greater than the task time due to ' +
1204 'parallel execution.',
1205 'orderfield': _get_toggle_order(request, "cpu_time_user", True),
1206 'ordericon':_get_toggle_order_icon(request, "cpu_time_user"),
1207 'orderkey' : 'cpu_time_user',
1208 'clclass': 'cpu_time_user', 'hidden' : 1,
1209 }
1210
1211 if 'cputime' == variant:
1212 tc_cpu_time_system['hidden']='0'
1213 tc_cpu_time_user['hidden']='0'
1214 del tc_cpu_time_system['clclass']
1215 del tc_cpu_time_user['clclass']
1216 tc_cache['hidden']='1'
1217
1218 tc_diskio={
1219 'name':'Disk I/O (bytes)',
1220 'qhelp':'Number of bytes written to and read from the disk during the task',
1221 'orderfield': _get_toggle_order(request, "disk_io", True),
1222 'ordericon':_get_toggle_order_icon(request, "disk_io"),
1223 'orderkey' : 'disk_io',
1224 'clclass': 'disk_io', 'hidden' : 1,
1225 }
1226 if 'diskio' == variant:
1227 tc_diskio['hidden']='0'
1228 del tc_diskio['clclass']
1229 tc_cache['hidden']='1'
1230
1231 build = Build.objects.get(pk=build_id)
1232
1233 context = { 'objectname': variant,
1234 'object_search_display': object_search_display,
1235 'filter_search_display': filter_search_display,
1236 'mainheading': title_variant,
1237 'build': build,
1238 'project': build.project,
1239 'objects': task_objects,
1240 'default_orderby' : default_orderby,
1241 'search_term': search_term,
1242 'total_count': queryset_with_search.count(),
1243 'tablecols':[
1244 tc_order,
1245 tc_recipe,
1246 tc_recipe_version,
1247 tc_task,
1248 tc_executed,
1249 tc_outcome,
1250 tc_cache,
1251 tc_time,
1252 tc_cpu_time_system,
1253 tc_cpu_time_user,
1254 tc_diskio,
1255 ]}
1256
1257
1258 response = render(request, template, context)
1259 _set_parameters_values(pagesize, orderby, request)
1260 return response
1261
1262def tasks(request, build_id):
1263 return tasks_common(request, build_id, 'tasks', '')
1264
1265def tasks_task(request, build_id, task_id):
1266 return tasks_common(request, build_id, 'tasks', task_id)
1267
1268def buildtime(request, build_id):
1269 return tasks_common(request, build_id, 'buildtime', '')
1270
1271def diskio(request, build_id):
1272 return tasks_common(request, build_id, 'diskio', '')
1273
1274def cputime(request, build_id):
1275 return tasks_common(request, build_id, 'cputime', '')
1276
1277def configuration(request, build_id): 999def configuration(request, build_id):
1278 template = 'configuration.html' 1000 template = 'configuration.html'
1279 1001