ldhldh commited on
Commit
c088f6d
·
1 Parent(s): 2222282

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -4,7 +4,8 @@ import numpy as np
4
  import matplotlib.pyplot as plt
5
  from PIL import Image
6
  import copy
7
-
 
8
 
9
  sample_data = {
10
  "gpus" : {
@@ -26,7 +27,7 @@ sample_data = {
26
  },
27
  {
28
  'index': 2,
29
- 'timestamp': 1701157843.518921,
30
  'transactions': [
31
  {'id': 'Alice', 'kind': 'add', 'data': '16'},
32
  {'id': 'bob', 'kind': 'add', 'data': '16'},
@@ -38,7 +39,7 @@ sample_data = {
38
  },
39
  {
40
  'index': 3,
41
- 'timestamp': 1701157843.535392,
42
  'transactions': [
43
  {'id': 'Alice', 'kind': 'add', 'data': '16'},
44
  {'id': 'TOM', 'kind': 'add', 'data': '8'},
@@ -50,7 +51,7 @@ sample_data = {
50
  },
51
  {
52
  'index': 4,
53
- 'timestamp': 1701157843.545325,
54
  'transactions': [
55
  {'id': 'Alice', 'kind': 'inference', 'data': '16'},
56
  {'id': 'bob', 'kind': 'inference', 'data': '16'},
@@ -62,7 +63,7 @@ sample_data = {
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'},
@@ -85,7 +86,7 @@ timestamp_list = []
85
  name_list = []
86
  timestamp_gpu_data = []
87
  for block in sample_data['chain']:
88
- timestamp_list.append(block['timestamp'])
89
  for t in block['transactions']:
90
  if t['kind'] == "add":
91
  if not t['id'] in name_list:
@@ -108,7 +109,7 @@ col3.metric("Percent", f"{round(100 * used_gpu/total_gpu, 2)} %",)
108
 
109
  chart_data = pd.DataFrame(timestamp_gpu_data, columns = name_list, index = timestamp_list)
110
 
111
- last_timestamp = sample_data['chain'][-1]['timestamp']
112
  st.area_chart(chart_data)
113
  st.caption(f'last updated in timestamp {last_timestamp}.')
114
 
 
4
  import matplotlib.pyplot as plt
5
  from PIL import Image
6
  import copy
7
+ import time
8
+ from time import strftime
9
 
10
  sample_data = {
11
  "gpus" : {
 
27
  },
28
  {
29
  'index': 2,
30
+ 'timestamp': 1701157845.518921,
31
  'transactions': [
32
  {'id': 'Alice', 'kind': 'add', 'data': '16'},
33
  {'id': 'bob', 'kind': 'add', 'data': '16'},
 
39
  },
40
  {
41
  'index': 3,
42
+ 'timestamp': 1701157846.535392,
43
  'transactions': [
44
  {'id': 'Alice', 'kind': 'add', 'data': '16'},
45
  {'id': 'TOM', 'kind': 'add', 'data': '8'},
 
51
  },
52
  {
53
  'index': 4,
54
+ 'timestamp': 1701157847.545325,
55
  'transactions': [
56
  {'id': 'Alice', 'kind': 'inference', 'data': '16'},
57
  {'id': 'bob', 'kind': 'inference', 'data': '16'},
 
63
  },
64
  {
65
  'index': 5,
66
+ 'timestamp': 1701157849.582371,
67
  'transactions': [
68
  {'id': 'Alice', 'kind': 'out', 'data': '16'},
69
  {'id': 'bob', 'kind': 'out', 'data': '16'},
 
86
  name_list = []
87
  timestamp_gpu_data = []
88
  for block in sample_data['chain']:
89
+ timestamp_list.append(strftime('%Y-%m-%d %I:%M:%S %p', localtime( block['timestamp'] )))
90
  for t in block['transactions']:
91
  if t['kind'] == "add":
92
  if not t['id'] in name_list:
 
109
 
110
  chart_data = pd.DataFrame(timestamp_gpu_data, columns = name_list, index = timestamp_list)
111
 
112
+ last_timestamp = strftime('%Y-%m-%d %I:%M:%S %p', localtime( sample_data['chain'][-1]['timestamp'] ))
113
  st.area_chart(chart_data)
114
  st.caption(f'last updated in timestamp {last_timestamp}.')
115