Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

add data visualization tool #12

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ use:
```bash
python -m report.console_tables --storage results/0001_bench.json
```
To see the results in a web browser you can use:
```bash
python reports/interactive_viewer.py <path>
```
where "path" is a JSON results file or a directory containing the JSON results
files. If using a directory, it is assummed all the data in the directory have
the same result format.

## Warning
This code is still under development. There are many razer sharp edges.
Expand Down
48 changes: 48 additions & 0 deletions report/interactive_viewer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""Interactive visualizer for results data"""

import argparse
import os
import json
import glob
import pandas as pd


def main(path, framework="dtale"):
"""
Start visualizer.

Args:
path (str): File or directory containing JSON formatted results
framework (str): visualization framework. Currently only 'dtale'.
"""
eda = __import__(framework)
if isinstance(path, list):
path_list = path
elif os.path.isdir(path):
path_list = glob.glob(path.rstrip("/ ") + "/*.json")
else:
path_list = [path]
df = pd.DataFrame()
result_data_list = []
for data_path in path_list:
with open(data_path, "r", encoding="utf8") as dfile:
result_data = json.load(dfile)
result_data_list.append({"benchmarks": result_data["benchmarks"], "file": data_path})
df = pd.json_normalize(result_data_list, record_path=["benchmarks"], meta=["file"])

session = eda.show(df, host="localhost", subprocess=False)
session.open_browser()


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--eda-framework",
default="dtale",
dest="framework",
choices=["dtale"],
help=("Exploratory data analysis framework. " "Currently only dtale is available."),
)
parser.add_argument("path", help="Path to directory or file for results.")
args = parser.parse_args()
main(args.path, args.framework)
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ qiskit-terra
pytket>1.0,<2.0
setproctitle
rich
pandas
dtale