Skip to content

Commit a6ee92f

Browse files
author
Craig Cornelius
authored
Set platform order from generation scripts (#502)
* Provide a way to reorder the executors in the summary table using command line of verifier * Updating Summary Dashboard to handle platform_order options in verifier * Minor fixes * As per comments
1 parent 1563b22 commit a6ee92f

File tree

6 files changed

+89
-7
lines changed

6 files changed

+89
-7
lines changed

genData100.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ pushd verifier
133133

134134
all_test_types=$(jq '.[].run.test_type' ../$source_file | jq -s '.' | jq 'add' | jq 'unique' | jq -r 'join(" ")')
135135
all_execs=$(jq -r 'join(" ")' <<< $all_execs_json)
136-
python3 verifier.py --file_base ../$TEMP_DIR --exec $all_execs --test_type $all_test_types
136+
137+
# Specifies the arrangement of the columns in the summary dashboard
138+
platform_order='ICU4C ICU4J ICU4X NodeJS Dart_Web Dart_Native'
139+
python3 verifier.py --file_base ../$TEMP_DIR --exec $all_execs --test_type $all_test_types --platform_order $platform_order
137140

138141
popd
139142

generateDataAndRun.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ pushd verifier
147147

148148
all_test_types=$(jq '.[].run.test_type' ../$source_file | jq -s '.' | jq 'add' | jq 'unique' | jq -r 'join(" ")')
149149
all_execs=$(jq -r 'join(" ")' <<< $all_execs_json)
150-
python3 verifier.py --file_base ../$TEMP_DIR --exec $all_execs --test_type $all_test_types
150+
151+
# Specifies the arrangement of the columns in the summary dashboard
152+
platform_order='ICU4C ICU4J ICU4X NodeJS Dart_Web Dart_Native'
153+
python3 verifier.py --file_base ../$TEMP_DIR --exec $all_execs --test_type $all_test_types --platform_order $platform_order
151154

152155
popd
153156

testdriver/ddtargs.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def __init__(self):
3939
'segmenter',
4040
'ALL']
4141

42+
# Note that spaces in an executor name are replaced by '_' here.
43+
# component_count is an option to sort by number of test types present in test output, with largest cout at the left
44+
# TODO: when a new platform is added, put it in this option list.
45+
platform_order_options = ['alphabetic', 'component_count', 'ICU4C', 'ICU4J', 'ICU4X', 'NodeJS', 'Dart_Web', 'Dart_Native']
46+
4247
class DdtArgs():
4348
def __init__(self, args):
4449
self.options = None # A simple namespace with each field
@@ -98,7 +103,16 @@ def __init__(self, args):
98103
self.parser.add_argument('--run_serial', default=None,
99104
help='Set if execution should be done serially. Parallel is the default.')
100105

106+
# Order the output columns
107+
self.parser.add_argument(
108+
'--platform_order',
109+
action='extend', nargs='*',
110+
choices=platform_order_options,
111+
help='The order of the platforms in the Summary dashboard, e.g., NodeJS ICU4X Dart_Web',
112+
default=None)
113+
101114
self.options = self.parser.parse_args(args)
115+
102116
return
103117

104118
def getOptions(self):

verifier/summary_template.html

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,70 @@
153153
// Sort output in alpha order by executor and by test_type
154154
const test_types = Object.keys(exec_summary_json);
155155
test_types.sort()
156-
/* Get all the execs */
156+
/* Get all the executed_platforms */
157157
let tests_by_type_and_exec = {};
158158

159159
// Find all the kinds of executors
160160
let exec_set = new Set();
161+
// And find how many tests are under each platform
162+
let exec_test_counts = {};
161163
for (const test_type of test_types) {
162164
const tests = exec_summary_json[test_type];
163165
for (const node_version of tests) {
164-
exec_set.add(node_version['version']['platform'])
166+
let this_exec = node_version['version']['platform'];
167+
exec_set.add(this_exec);
168+
if (this_exec in exec_test_counts) {
169+
exec_test_counts[this_exec] += 1;
170+
} else {
171+
exec_test_counts[this_exec] = 1;
172+
}
173+
}
174+
}
175+
176+
// If platform/exec order is specified, use that.
177+
let executed_platforms = [];
178+
// exec_set includes all those that are represented in the data
179+
const platform_order = ["$platform_order"];
180+
if (platform_order.length <= 0 || platform_order[0] == 'alphabetic'
181+
|| platform_order[0] == "None") {
182+
// Default is alphabetic sort
183+
executed_platforms = Array.from(exec_set).sort();
184+
} else {
185+
// Provided by the test report
186+
// Remove those that are not in the exec_set.
187+
if (platform_order[0] == 'component_count') {
188+
// Use to set the order
189+
const entries = Object.entries(exec_test_counts);
190+
// Sort with largest first
191+
entries.sort((a, b) => b[1] - a[1]);
192+
for (const [key, value] of entries) {
193+
executed_platforms.push(key);
194+
}
195+
} else {
196+
// Check for "alphabetic", "component_count", and other options.
197+
// Does this preserve order?
198+
// It should not exclude things that are in test results,
199+
// nor include things that are not there.
200+
let execs_missing_set =
201+
new Set(Array.from(exec_set));
202+
for (let platform of platform_order) {
203+
// remove the underscores, too.
204+
const pl2 = platform.replaceAll('_', ' ');
205+
if (exec_set.has(pl2)) {
206+
executed_platforms.push(pl2);
207+
execs_missing_set.delete(pl2);
208+
}
209+
}
210+
// Make sure all the items from exec set are there, too.
211+
execs_missing_set.forEach(platform => executed_platforms.push(platform));
165212
}
166213
}
167214

168-
const execs = Array.from(exec_set).sort();
169215
let th = table.insertRow();
170216
let td = th.insertCell();
171217
td.innerHTML = "Test Type";
172218

173-
for (const exec of execs) {
219+
for (const exec of executed_platforms) {
174220
td = th.insertCell();
175221
td.innerHTML = exec;
176222
td.style.textAlign = 'center';
@@ -185,7 +231,7 @@
185231
td.innerHTML = test_type
186232

187233
const tests = exec_summary_json[test_type];
188-
for (const exec of execs) {
234+
for (const exec of executed_platforms) {
189235
// Get all the report info for this test and this exec
190236
let reports = [];
191237
let data = [data_groups];

verifier/testreport.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,9 @@ def __init__(self, file_base):
11651165

11661166
self.templates = reportTemplate()
11671167

1168+
# Order left-to-right of platforms in summary dashboard
1169+
self.platform_order = []
1170+
11681171
if self.debug > 1:
11691172
logging.info('SUMMARY REPORT base = %s', self.file_base)
11701173

@@ -1290,12 +1293,19 @@ def summarize_reports(self):
12901293
def create_summary_html(self):
12911294
# Generate HTML page containing this information
12921295
# Create the template
1296+
1297+
platform_string_for_template = None
1298+
if any(self.platform_order):
1299+
platform_string_for_template = '", "'.join(self.platform_order)
1300+
12931301
html_map = {
12941302
'all_platforms': ', '.join(list(self.exec_summary.keys())),
12951303
'all_icu_versions': None, # TEMP!!!
12961304
'all_tests': ', '.join(list(self.type_summary.keys())),
12971305
'datetime': datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
1306+
'platform_order': platform_string_for_template
12981307
}
1308+
12991309
# Create header for each executor
13001310
header_line = '' # TODO
13011311
html_map['header_line'] = header_line

verifier/verifier.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def setup_verify_plans(self):
129129
# Generates exec and test lists from the existing files in
130130
# testResults directories
131131
summary_report = SummaryReport(self.file_base)
132+
132133
summary_report.summarize_reports()
133134
executor_list = summary_report.exec_summary.keys()
134135
test_list = summary_report.type_summary.keys()
@@ -307,6 +308,11 @@ def create_summary_reports(self):
307308
summary_report = SummaryReport(self.file_base)
308309
summary_report.setup_all_test_results()
309310

311+
312+
if self.options.platform_order:
313+
# Set the order of the platforms in the summary dashboard
314+
summary_report.platform_order = self.options.platform_order
315+
310316
# Get schema summary data to the testReport head
311317
schema_validation_list = self.schema_results()
312318

0 commit comments

Comments
 (0)