ldhldh commited on
Commit
2902e3a
·
1 Parent(s): 767dd9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -12
app.py CHANGED
@@ -4,18 +4,6 @@ import numpy as np
4
  import matplotlib.pyplot as plt
5
  from PIL import Image
6
 
7
- user_num = 7
8
- total_gpu = 32
9
- used_gpu = 22
10
-
11
- col1, col2, col3 = st.columns(3)
12
- col1.metric("Total GPU", f"{total_gpu} GB", f"{user_num} users are sharing now")
13
- col2.metric("Used", f"{used_gpu} GB")
14
- col3.metric("Percent", f"{100 * used_gpu/total_gpu} %",)
15
-
16
- chart_data = pd.DataFrame(np.random.randn(20, 3))
17
-
18
- st.area_chart(chart_data)
19
 
20
 
21
  sample_data = {
@@ -72,10 +60,54 @@ sample_data = {
72
  ],
73
  'previous_hash':'5199cc3018287cf3f5fffbb0d1ae3f949256774a2347401818bdc93d29c379e8'
74
  },
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  ]
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  class BubbleChart:
80
  def __init__(self, data, bubble_spacing=0, n_bins=5):
81
 
 
4
  import matplotlib.pyplot as plt
5
  from PIL import Image
6
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
 
9
  sample_data = {
 
60
  ],
61
  'previous_hash':'5199cc3018287cf3f5fffbb0d1ae3f949256774a2347401818bdc93d29c379e8'
62
  },
63
+ {
64
+ 'index': 5,
65
+ 'timestamp': 1701157843.582371,
66
+ 'transactions': [
67
+ {'id': 'Alice', 'kind': 'out', 'data': '16'},
68
+ {'id': 'bob', 'kind': 'out', 'data': '16'},
69
+ {'id': 'Alice', 'kind': 'inference', 'data': 'Hello?'},
70
+ {'id': 'Alice', 'kind': 'out', 'data': '16'},
71
+ {'id': 'bob', 'kind': 'out', 'data': '16'}
72
+ ],
73
+ 'previous_hash':'5199cc3018287cf3f5fffbb0d1ae3f949256774a2347401818bdc93d29c379e8'
74
+ },
75
 
76
  ]
77
  }
78
 
79
+
80
+ user_num = len(sample_data['gpus'].items())
81
+ total_gpu = sample_data['total']['total']
82
+ used_gpu = sample_data['total']['used']
83
+
84
+ name_list = []
85
+ timestamp_gpu_data = []
86
+ for block in sample_data['chain']:
87
+ for t in block['transactions']:
88
+ if t['kind'] == "add":
89
+ if not t['id'] in name_list:
90
+ name_list.append(t['id'])
91
+
92
+ timestamp_gpu_data = [[0 for _ in range(len(name_list))]]
93
+ for block in sample_data['chain']:
94
+ temp = timestamp_gpu_data[block['index']]
95
+ for t in block['transactions']:
96
+ if t['kind'] == "add":
97
+ temp[name_list.find(t['id'])] += int(t['data'])
98
+ elif t['kind'] == "out":
99
+ temp[name_list.find(t['id'])] = 0
100
+
101
+ col1, col2, col3 = st.columns(3)
102
+ col1.metric("Total GPU", f"{total_gpu} GB", f"{user_num} users are sharing now")
103
+ col2.metric("Used", f"{used_gpu} GB")
104
+ col3.metric("Percent", f"{100 * used_gpu/total_gpu} %",)
105
+
106
+ chart_data = pd.DataFrame(timestamp_gpu_data)
107
+
108
+ st.area_chart(chart_data)
109
+
110
+
111
  class BubbleChart:
112
  def __init__(self, data, bubble_spacing=0, n_bins=5):
113