lotus/scripts/snapshot-summary.py

31 lines
748 B
Python
Raw Normal View History

2023-06-27 06:54:02 +00:00
import plotly.express as px
import sys, json
2023-06-27 17:00:20 +00:00
import pathlib
2023-06-27 06:54:02 +00:00
snapshot_data = json.load(sys.stdin)
2023-06-28 15:15:38 +00:00
# Possible extensions:
# 1. parameterize to use block count as value instead of byte size
# 2. parameterize on different types of px chart types
# 3. parameterize on output port so we can serve this from infra
2023-06-27 06:54:02 +00:00
parents = []
names = []
values = []
for key in snapshot_data:
2023-06-27 17:00:20 +00:00
path = pathlib.Path(key)
name = key
parent = str(path.parent)
if key == '/':
parent = ''
2023-06-27 06:54:02 +00:00
stats = snapshot_data[key]
parents.append(parent)
names.append(name)
values.append(stats['Size'])
data = dict(names=names, parents=parents, values=values)
fig = px.treemap(data, names='names', parents='parents', values='values')
fig.show()