Skip to content

Commit 4019fdd

Browse files
fviernautsteenbe
authored andcommitted
feat(evaluated-model)!: Include metadata for all tool runs
Prepare for showing that metadata in the WebApp. Signed-off-by: Frank Viernau <frank.viernau@gmail.com>
1 parent 0357a3a commit 4019fdd

8 files changed

Lines changed: 243 additions & 47 deletions

plugins/reporters/evaluated-model/src/funTest/resources/evaluated-model-reporter-test-deduplicate-expected-output.yml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,5 +1270,48 @@ labels:
12701270
process_parameters.PROCESS_PARAM_1: "label process param 1"
12711271
process_parameters.PROCESS_PARAM_2: "label process param 2"
12721272
OTHER: "label other"
1273-
metadata:
1274-
analyzer_start_time: "1970-01-01T00:00:00Z"
1273+
tools_metadata:
1274+
analyzer:
1275+
start_time: "1970-01-01T00:00:00Z"
1276+
end_time: "1970-01-01T00:35:05Z"
1277+
environment:
1278+
ort_version: "72463cc"
1279+
build_jdk: "21.0.7+6-LTS"
1280+
java_version: "1.8.0_181"
1281+
os: "Linux"
1282+
processors: 8
1283+
max_memory: 8321499136
1284+
variables: {}
1285+
scanner:
1286+
start_time: "1970-01-01T00:40:00Z"
1287+
end_time: "1970-01-01T00:48:00Z"
1288+
environment:
1289+
ort_version: "72463cc"
1290+
build_jdk: "21.0.7+6-LTS"
1291+
java_version: "1.8.0_181"
1292+
os: "Linux"
1293+
processors: 8
1294+
max_memory: 8321499136
1295+
variables: {}
1296+
advisor:
1297+
start_time: "1970-01-01T01:01:00Z"
1298+
end_time: "1970-01-01T01:08:00Z"
1299+
environment:
1300+
ort_version: "72463cc"
1301+
build_jdk: "21.0.7+6-LTS"
1302+
java_version: "1.8.0_181"
1303+
os: "Linux"
1304+
processors: 8
1305+
max_memory: 8321499136
1306+
variables: {}
1307+
evaluator:
1308+
start_time: "1970-01-01T01:09:00Z"
1309+
end_time: "1970-01-01T01:11:00Z"
1310+
environment:
1311+
ort_version: "72463cc"
1312+
build_jdk: "21.0.7+6-LTS"
1313+
java_version: "1.8.0_181"
1314+
os: "Linux"
1315+
processors: 8
1316+
max_memory: 8321499136
1317+
variables: {}

plugins/reporters/evaluated-model/src/funTest/resources/evaluated-model-reporter-test-expected-output.json

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,58 @@
13571357
"process_parameters.PROCESS_PARAM_2" : "label process param 2",
13581358
"OTHER" : "label other"
13591359
},
1360-
"metadata" : {
1361-
"analyzer_start_time" : "1970-01-01T00:00:00Z"
1360+
"tools_metadata" : {
1361+
"analyzer" : {
1362+
"start_time" : "1970-01-01T00:00:00Z",
1363+
"end_time" : "1970-01-01T00:35:05Z",
1364+
"environment" : {
1365+
"ort_version" : "72463cc",
1366+
"build_jdk" : "21.0.7+6-LTS",
1367+
"java_version" : "1.8.0_181",
1368+
"os" : "Linux",
1369+
"processors" : 8,
1370+
"max_memory" : 8321499136,
1371+
"variables" : { }
1372+
}
1373+
},
1374+
"scanner" : {
1375+
"start_time" : "1970-01-01T00:40:00Z",
1376+
"end_time" : "1970-01-01T00:48:00Z",
1377+
"environment" : {
1378+
"ort_version" : "72463cc",
1379+
"build_jdk" : "21.0.7+6-LTS",
1380+
"java_version" : "1.8.0_181",
1381+
"os" : "Linux",
1382+
"processors" : 8,
1383+
"max_memory" : 8321499136,
1384+
"variables" : { }
1385+
}
1386+
},
1387+
"advisor" : {
1388+
"start_time" : "1970-01-01T01:01:00Z",
1389+
"end_time" : "1970-01-01T01:08:00Z",
1390+
"environment" : {
1391+
"ort_version" : "72463cc",
1392+
"build_jdk" : "21.0.7+6-LTS",
1393+
"java_version" : "1.8.0_181",
1394+
"os" : "Linux",
1395+
"processors" : 8,
1396+
"max_memory" : 8321499136,
1397+
"variables" : { }
1398+
}
1399+
},
1400+
"evaluator" : {
1401+
"start_time" : "1970-01-01T01:09:00Z",
1402+
"end_time" : "1970-01-01T01:11:00Z",
1403+
"environment" : {
1404+
"ort_version" : "72463cc",
1405+
"build_jdk" : "21.0.7+6-LTS",
1406+
"java_version" : "1.8.0_181",
1407+
"os" : "Linux",
1408+
"processors" : 8,
1409+
"max_memory" : 8321499136,
1410+
"variables" : { }
1411+
}
1412+
}
13621413
}
13631414
}

plugins/reporters/evaluated-model/src/funTest/resources/evaluated-model-reporter-test-expected-output.yml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,5 +1270,48 @@ labels:
12701270
process_parameters.PROCESS_PARAM_1: "label process param 1"
12711271
process_parameters.PROCESS_PARAM_2: "label process param 2"
12721272
OTHER: "label other"
1273-
metadata:
1274-
analyzer_start_time: "1970-01-01T00:00:00Z"
1273+
tools_metadata:
1274+
analyzer:
1275+
start_time: "1970-01-01T00:00:00Z"
1276+
end_time: "1970-01-01T00:35:05Z"
1277+
environment:
1278+
ort_version: "72463cc"
1279+
build_jdk: "21.0.7+6-LTS"
1280+
java_version: "1.8.0_181"
1281+
os: "Linux"
1282+
processors: 8
1283+
max_memory: 8321499136
1284+
variables: {}
1285+
scanner:
1286+
start_time: "1970-01-01T00:40:00Z"
1287+
end_time: "1970-01-01T00:48:00Z"
1288+
environment:
1289+
ort_version: "72463cc"
1290+
build_jdk: "21.0.7+6-LTS"
1291+
java_version: "1.8.0_181"
1292+
os: "Linux"
1293+
processors: 8
1294+
max_memory: 8321499136
1295+
variables: {}
1296+
advisor:
1297+
start_time: "1970-01-01T01:01:00Z"
1298+
end_time: "1970-01-01T01:08:00Z"
1299+
environment:
1300+
ort_version: "72463cc"
1301+
build_jdk: "21.0.7+6-LTS"
1302+
java_version: "1.8.0_181"
1303+
os: "Linux"
1304+
processors: 8
1305+
max_memory: 8321499136
1306+
variables: {}
1307+
evaluator:
1308+
start_time: "1970-01-01T01:09:00Z"
1309+
end_time: "1970-01-01T01:11:00Z"
1310+
environment:
1311+
ort_version: "72463cc"
1312+
build_jdk: "21.0.7+6-LTS"
1313+
java_version: "1.8.0_181"
1314+
os: "Linux"
1315+
processors: 8
1316+
max_memory: 8321499136
1317+
variables: {}

plugins/reporters/evaluated-model/src/main/kotlin/EvaluatedModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ data class EvaluatedModel(
123123

124124
val labels: Map<String, String>,
125125

126-
val metadata: Metadata
126+
val toolsMetadata: ToolsMetadata
127127
) {
128128
companion object {
129129
private val INT_ID_TYPES = listOf(

plugins/reporters/evaluated-model/src/main/kotlin/EvaluatedModelMapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ internal class EvaluatedModelMapper(private val input: ReporterInput) {
182182
severeRuleViolationThreshold = input.ortConfig.severeRuleViolationThreshold,
183183
repositoryConfiguration = input.ortResult.repository.config.toYaml(),
184184
labels = input.ortResult.labels,
185-
metadata = MetadataCalculator().getMetadata(input.ortResult)
185+
toolsMetadata = ToolsMetadataCalculator().getMetadata(input.ortResult)
186186
)
187187
}
188188

plugins/reporters/evaluated-model/src/main/kotlin/MetadataCalculator.kt

Lines changed: 0 additions & 34 deletions
This file was deleted.

plugins/reporters/evaluated-model/src/main/kotlin/Metadata.kt renamed to plugins/reporters/evaluated-model/src/main/kotlin/ToolsMetadata.kt

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,46 @@ package org.ossreviewtoolkit.plugins.reporters.evaluatedmodel
2121

2222
import java.time.Instant
2323

24+
import org.ossreviewtoolkit.utils.ort.Environment
25+
2426
/**
25-
* Metadata about the ORT run itself.
27+
* Metadata about the ORT tool runs.
2628
*/
27-
data class Metadata(
29+
data class ToolsMetadata(
30+
/**
31+
* The metadata for the analyzer run.
32+
*/
33+
val analyzer: Run?,
34+
35+
/**
36+
* The metadata for the scanner run.
37+
*/
38+
val scanner: Run?,
39+
40+
/**
41+
* The metadata for the advisor run.
42+
*/
43+
val advisor: Run?,
44+
2845
/**
29-
* The time the Analyzer started.
46+
* The metadata for the evaluator run.
3047
*/
31-
val analyzerStartTime: Instant
32-
)
48+
val evaluator: Run?
49+
) {
50+
data class Run(
51+
/**
52+
* The time the run started.
53+
*/
54+
val startTime: Instant,
55+
56+
/**
57+
* The time the run started.
58+
*/
59+
val endTime: Instant,
60+
61+
/**
62+
* The [Environment] in which the run was executed.
63+
*/
64+
val environment: Environment
65+
)
66+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright (C) 2021 The ORT Project Copyright Holders <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-License-Identifier: Apache-2.0
17+
* License-Filename: LICENSE
18+
*/
19+
20+
package org.ossreviewtoolkit.plugins.reporters.evaluatedmodel
21+
22+
import org.ossreviewtoolkit.model.OrtResult
23+
24+
/**
25+
* This class calculates [ToolsMetadata] for a given [OrtResult].
26+
*/
27+
internal class ToolsMetadataCalculator {
28+
fun getMetadata(ortResult: OrtResult) =
29+
ToolsMetadata(
30+
analyzer = ortResult.analyzer?.let { run ->
31+
ToolsMetadata.Run(
32+
startTime = run.startTime,
33+
endTime = run.endTime,
34+
environment = run.environment
35+
)
36+
},
37+
scanner = ortResult.scanner?.let { run ->
38+
ToolsMetadata.Run(
39+
startTime = run.startTime,
40+
endTime = run.endTime,
41+
environment = run.environment
42+
)
43+
},
44+
advisor = ortResult.advisor?.let { run ->
45+
ToolsMetadata.Run(
46+
startTime = run.startTime,
47+
endTime = run.endTime,
48+
environment = run.environment
49+
)
50+
},
51+
evaluator = ortResult.evaluator?.let { run ->
52+
ToolsMetadata.Run(
53+
startTime = run.startTime,
54+
endTime = run.endTime,
55+
environment = run.environment
56+
)
57+
}
58+
)
59+
}

0 commit comments

Comments
 (0)