Skip to content

Commit 31d46d7

Browse files
authored
[importreport] Allow specifying additional run information to include in the submission (#151)
Fixes #150
1 parent a8f2bc3 commit 31d46d7

File tree

3 files changed

+98
-3
lines changed

3 files changed

+98
-3
lines changed

docs/importing_data.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ Example::
2323
lnt importreport --machine=my-machine-name --order=1234 --testsuite=nts results.txt report.json
2424
lnt submit http://mylnt.com/db_default/submitRun report.json
2525

26+
Additional information can also be included in runs. This can be useful to include e.g. the
27+
commit information associated to the version of the code being benchmarked or other information
28+
relevant to the run like the system load, etc. This information can be provided to ``lnt importreport``
29+
as key-value pairs, passing ``--run-info`` as many times as necessary::
30+
31+
lnt importreport --machine=my-machine-name --order=1234 --testsuite=nts \
32+
--run-info commit="COMMIT INFORMATION" \
33+
--run-info machine_load="LOAD INFORMATION" \
34+
results.txt report.json
35+
2636
.. _json_format:
2737

2838
LNT Report File Format

lnt/lnttool/import_report.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@
1212
"Ex: a svn revision, or timestamp.")
1313
@click.option("--machine", required=True,
1414
help="the name of the machine to submit under")
15-
def action_importreport(input, output, suite, order, machine):
15+
@click.option("--run-info", multiple=True, type=str,
16+
help="Optional additional run information to include in the submission. "
17+
"If provided, this must be a key-value pair separated by '='. This "
18+
"argument may be repeated multiple times to provide multiple keys "
19+
"and values in the run information.")
20+
def action_importreport(input, output, suite, order, machine, run_info):
1621
"""Import simple data into LNT. This takes a space separated
1722
key value file and creates an LNT report file, which can be submitted to
18-
an LNT server. Example input file:
23+
an LNT server. Example input file:
1924
2025
\b
2126
foo.exec 123
@@ -30,10 +35,19 @@ def action_importreport(input, output, suite, order, machine):
3035

3136
machine = lnt.testing.Machine(machine, report_version=2)
3237

38+
parsed_info = {}
39+
for s in run_info:
40+
if '=' not in s:
41+
raise click.BadParameter(f"--run-info must be in 'key=value' format, got: {s}")
42+
k, v = s.split('=', 1) # Split only on the first '=' in case there are several in the string
43+
parsed_info[k] = v
44+
run_info = parsed_info
45+
run_info.update({'llvm_project_revision': order})
46+
3347
ctime = os.path.getctime(input.name)
3448
mtime = os.path.getmtime(input.name)
3549
run = lnt.testing.Run(start_time=ctime, end_time=mtime,
36-
info={'llvm_project_revision': order},
50+
info=run_info,
3751
report_version=2)
3852

3953
tests = {} # name => lnt.testing.Test
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#
2+
# Ensure that we can pass additional run information with `lnt importreport`.
3+
#
4+
5+
# Pass one run information.
6+
#
7+
# RUN: lnt importreport --testsuite nts --order 123 --machine foo --run-info commit=abc123 %S/Inputs/example_metrics.lnt %t.1.json
8+
# RUN: filecheck --check-prefix=CHECK-1 --input-file %t.1.json %s
9+
# CHECK-1: {
10+
# CHECK-1-NEXT: "format_version": "2",
11+
# CHECK-1-NEXT: "machine": {
12+
# CHECK-1-NEXT: "name": "foo"
13+
# CHECK-1-NEXT: },
14+
# CHECK-1-NEXT: "run": {
15+
# CHECK-1-NEXT: "commit": "abc123",
16+
# CHECK-1-NEXT: "end_time": "{{.+}}",
17+
# CHECK-1-NEXT: "llvm_project_revision": "123",
18+
# CHECK-1-NEXT: "start_time": "{{.+}}"
19+
# CHECK-1-NEXT: },
20+
# CHECK-1-NEXT: "tests": [
21+
# CHECK-1-NEXT: {
22+
# CHECK-1-NEXT: "execution_time": [
23+
# CHECK-1-NEXT: 10.0,
24+
# CHECK-1-NEXT: 11.0
25+
# CHECK-1-NEXT: ],
26+
# CHECK-1-NEXT: "hash": "d7",
27+
# CHECK-1-NEXT: "name": "foo"
28+
# CHECK-1-NEXT: },
29+
# CHECK-1-NEXT: {
30+
# CHECK-1-NEXT: "execution_time": 20.0,
31+
# CHECK-1-NEXT: "name": "bar",
32+
# CHECK-1-NEXT: "profile": "Xz6/"
33+
# CHECK-1-NEXT: }
34+
# CHECK-1-NEXT: ]
35+
# CHECK-1-NEXT: }
36+
37+
# Pass multiple run informations.
38+
#
39+
# RUN: lnt importreport --testsuite nts --order 123 --machine foo \
40+
# RUN: --run-info commit=abc123 --run-info load_factor="10%" --run-info something_else="info" \
41+
# RUN: %S/Inputs/example_metrics.lnt %t.2.json
42+
# RUN: filecheck --check-prefix=CHECK-2 --input-file %t.2.json %s
43+
# CHECK-2: {
44+
# CHECK-2-NEXT: "format_version": "2",
45+
# CHECK-2-NEXT: "machine": {
46+
# CHECK-2-NEXT: "name": "foo"
47+
# CHECK-2-NEXT: },
48+
# CHECK-2-NEXT: "run": {
49+
# CHECK-2-NEXT: "commit": "abc123",
50+
# CHECK-2-NEXT: "end_time": "{{.+}}",
51+
# CHECK-2-NEXT: "llvm_project_revision": "123",
52+
# CHECK-2-NEXT: "load_factor": "10%",
53+
# CHECK-2-NEXT: "something_else": "info",
54+
# CHECK-2-NEXT: "start_time": "{{.+}}"
55+
# CHECK-2-NEXT: },
56+
# CHECK-2-NEXT: "tests": [
57+
# CHECK-2-NEXT: {
58+
# CHECK-2-NEXT: "execution_time": [
59+
# CHECK-2-NEXT: 10.0,
60+
# CHECK-2-NEXT: 11.0
61+
# CHECK-2-NEXT: ],
62+
# CHECK-2-NEXT: "hash": "d7",
63+
# CHECK-2-NEXT: "name": "foo"
64+
# CHECK-2-NEXT: },
65+
# CHECK-2-NEXT: {
66+
# CHECK-2-NEXT: "execution_time": 20.0,
67+
# CHECK-2-NEXT: "name": "bar",
68+
# CHECK-2-NEXT: "profile": "Xz6/"
69+
# CHECK-2-NEXT: }
70+
# CHECK-2-NEXT: ]
71+
# CHECK-2-NEXT: }

0 commit comments

Comments
 (0)