-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from AhmedBasem20/test-results-file
Save test results to a json file & Display results Visuals on the website
- Loading branch information
Showing
6 changed files
with
148 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ tqdm | |
pandas | ||
sphinx | ||
sphinx_rtd_theme | ||
pytest-json-report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import pathlib | ||
import json | ||
import sys | ||
|
||
def summarize_test_report(input_file:str, output_file:str): | ||
file = pathlib.Path(__file__) | ||
report_path = file.with_name(input_file) | ||
with report_path.open() as f: | ||
report_info = json.load(f) | ||
summary = [] | ||
for test_case in report_info['tests']: | ||
values = test_case['user_properties'][0]['test_data'] | ||
values['status'] = test_case['outcome'] | ||
summary.append(values) | ||
|
||
with open(output_file, 'w') as f: | ||
json.dump(summary, f, indent=4) | ||
|
||
if __name__ == '__main__': | ||
if len(sys.argv) != 3: | ||
print("Usage: python report-summary.py <input_file> <output_file>") | ||
sys.exit(1) | ||
|
||
input_file = sys.argv[1] | ||
output_file = sys.argv[2] | ||
summarize_test_report(input_file, output_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pako.min.js"></script> | ||
<script src="index.js"></script> | ||
<script src="test_plots.js"></script> | ||
<link rel="stylesheet" href="index.css"> | ||
</head> | ||
<body> | ||
|
@@ -97,6 +98,12 @@ <h1 class="bar-title">IVIM MRI Algorithm Fitting Dashboard</h1> | |
<div class="chart-card" id="regionDiv"> | ||
<!-- New chart will be rendered here --> | ||
</div> | ||
<h1>Validation Data Plots</h1> | ||
<div style="display: flex; flex-direction: column; gap: 1rem;"> | ||
<div class="chart-card" id="plot_f_fit" "></div> | ||
<div class="chart-card" id="plot_Dp_fit" "></div> | ||
<div class="chart-card" id="plot_D_fit" "></div> | ||
</div> | ||
|
||
|
||
</main> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
document.addEventListener('DOMContentLoaded', function() { | ||
fetch('report-summary.json') | ||
.then(response => response.json()) | ||
.then(data => { | ||
function createPlot(container, parameter) { | ||
var reference_values = data.map(d => d[parameter]); | ||
var fit_values = data.map(d => d[parameter + '_fit']); | ||
var minRefValue = Math.min(...reference_values); | ||
var maxRefValue = Math.max(...reference_values); | ||
// Create a range for tolerance trace x axis. | ||
var xRange = [minRefValue, maxRefValue]; | ||
// var DefaultTolerance = { | ||
// "rtol": { | ||
// "f": 0.05, | ||
// "D": 2, | ||
// "Dp": 0.5 | ||
// }, | ||
// "atol": { | ||
// "f": 0.2, | ||
// "D": 0.001, | ||
// "Dp": 0.06 | ||
// } | ||
// } | ||
var DefaultTolerance = data[1] //Majority of the dataset has this tolerance values | ||
var tolerance = xRange.map((d) => DefaultTolerance['atol'][parameter] + DefaultTolerance['rtol'][parameter] * d); | ||
var negative_tolerance = tolerance.map(t => -t); | ||
|
||
var errors = fit_values.map((d, i) => (d - reference_values[i])); | ||
|
||
// Define colors for each status | ||
var statusColors = { | ||
'passed': 'green', | ||
'xfailed': 'blue', | ||
'failed': 'red' | ||
}; | ||
|
||
// Assign color based on the status | ||
var marker_colors = data.map(entry => statusColors[entry.status]); | ||
|
||
var scatter_trace = { | ||
x: reference_values, | ||
y: errors, | ||
mode: 'markers', | ||
type: 'scatter', | ||
name: `${parameter} fitting values`, | ||
text: data.map(entry => `Algorithm: ${entry.algorithm} Region: ${entry.name}`), | ||
marker: { | ||
color: marker_colors | ||
} | ||
}; | ||
|
||
var tolerance_trace = { | ||
x: xRange, | ||
y: tolerance, | ||
type: 'scatter', | ||
mode: 'lines', | ||
line: { dash: 'dash', color: 'black' }, | ||
name: 'Positive Tolerance' | ||
}; | ||
|
||
var negative_tolerance_trace = { | ||
x: xRange, | ||
y: negative_tolerance, | ||
type: 'scatter', | ||
mode: 'lines', | ||
line: { dash: 'dash', color: 'black' }, | ||
name: 'Negative Tolerance' | ||
}; | ||
|
||
var layout = { | ||
title: `Error Plot for ${parameter.toUpperCase()}_fit with Tolerance Bands`, | ||
xaxis: { title: `Reference ${parameter.toUpperCase()} Values` }, | ||
yaxis: { title: `Error (${parameter}_fit - Reference ${parameter})` } | ||
}; | ||
|
||
var plot_data = [scatter_trace, tolerance_trace, negative_tolerance_trace]; | ||
|
||
Plotly.newPlot(container, plot_data, layout); | ||
} | ||
|
||
createPlot('plot_f_fit', 'f'); | ||
createPlot('plot_Dp_fit', 'Dp'); | ||
createPlot('plot_D_fit', 'D'); | ||
}); | ||
}); |