JSON log transform script not working
Benchmark logs produced by the run-tnl-benchmark-spmv script fail to be parsed by the JSON parser script tnl-spmv-benchmark-make-tables-json.py with the following error:
Parsing input file....
Traceback (most recent call last):
File "tnl-spmv-benchmark-make-tables-json.py", line 956, in <module>
d = json.load(f)
File "/usr/lib/python3.8/json/__init__.py", line 293, in load
return loads(fp.read(),
File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.8/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 444)
How to reproduce:
- If you don't have any matrices set up in the script directory, ten you can briefly run the get-matrices script to download some into used folder "scripts/mtx_matrices".
- Run spmv benchmarks using the run-tnl-benchmark-spmv script.
- Convert the benchmark JSON logs using the tnl-spmv-benchmark-make-tables-json.py](https://mmg-gitlab.fjfi.cvut.cz/gitlab/tnl/tnl-dev/-/blob/develop/src/Benchmarks/scripts/tnl-spmv-benchmark-make-tables-json.py) script.
Expected behaviour:
- The python script will convert the log file containing JSON results of benchmarks to an html file.
Actual behaviour:
- The python script fails since the logs are not a valid JSON as a whole, rather, every line is a valid JSON on its own (source: @klinkovsky).
Notes:
- Loading the entire JSON from the logs won't work, each line will have to be parsed separately.
For example:
data = [] for line in open("sparse-matrix-benchmark.log").readlines(): data.append(json.loads(line))
- When working with tables in Python, @klinkovsky recommends to use the Pandas library. Specifically, to load logs to Pandas dataframe, the following function can be used: link to file.
- Example log file: sparse-matrix-benchmark.log.