Spaces:
Runtime error
Runtime error
Update
Browse files- demo_list.py +15 -1
- style.css +5 -0
demo_list.py
CHANGED
@@ -25,7 +25,8 @@ class DemoList:
|
|
25 |
['sdk', 'markdown'],
|
26 |
['sdk_version', 'str'],
|
27 |
['suggested_hardware', 'markdown'],
|
28 |
-
['sleep_time', '
|
|
|
29 |
]
|
30 |
|
31 |
TO_TIME_STR = {
|
@@ -81,6 +82,9 @@ class DemoList:
|
|
81 |
info['last_modified'] = space_info.lastModified
|
82 |
info['status'] = space_info.runtime['stage']
|
83 |
info['sleep_time'] = space_info.runtime['gcTimeout'] or -1
|
|
|
|
|
|
|
84 |
info['suggested_hardware'] = card.get('suggested_hardware', '')
|
85 |
info['hardware'] = space_info.runtime['hardware']['current']
|
86 |
if info['hardware'] is None:
|
@@ -114,6 +118,14 @@ class DemoList:
|
|
114 |
s = datetime.datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.000Z')
|
115 |
return s.strftime('%Y/%m/%d %H:%M:%S')
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
def prettify_df(self) -> pd.DataFrame:
|
118 |
new_rows = []
|
119 |
for _, row in self.df_raw.copy().iterrows():
|
@@ -147,6 +159,8 @@ class DemoList:
|
|
147 |
row.sdk_version,
|
148 |
'sleep_time':
|
149 |
self.TO_TIME_STR[row.sleep_time],
|
|
|
|
|
150 |
}
|
151 |
new_rows.append(new_row)
|
152 |
df = pd.DataFrame(new_rows).loc[:, self.column_names]
|
|
|
25 |
['sdk', 'markdown'],
|
26 |
['sdk_version', 'str'],
|
27 |
['suggested_hardware', 'markdown'],
|
28 |
+
['sleep_time', 'markdown'],
|
29 |
+
['replicas', 'markdown'],
|
30 |
]
|
31 |
|
32 |
TO_TIME_STR = {
|
|
|
82 |
info['last_modified'] = space_info.lastModified
|
83 |
info['status'] = space_info.runtime['stage']
|
84 |
info['sleep_time'] = space_info.runtime['gcTimeout'] or -1
|
85 |
+
resources = space_info.runtime['resources']
|
86 |
+
info['replicas'] = -1 if resources is None else resources[
|
87 |
+
'replicas']
|
88 |
info['suggested_hardware'] = card.get('suggested_hardware', '')
|
89 |
info['hardware'] = space_info.runtime['hardware']['current']
|
90 |
if info['hardware'] is None:
|
|
|
118 |
s = datetime.datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.000Z')
|
119 |
return s.strftime('%Y/%m/%d %H:%M:%S')
|
120 |
|
121 |
+
@staticmethod
|
122 |
+
def add_div_tag_to_replicas(replicas: int) -> str:
|
123 |
+
if replicas == -1:
|
124 |
+
return ''
|
125 |
+
if replicas == 1:
|
126 |
+
return '1'
|
127 |
+
return f'<div class="multiple-replicas">{replicas}</div>'
|
128 |
+
|
129 |
def prettify_df(self) -> pd.DataFrame:
|
130 |
new_rows = []
|
131 |
for _, row in self.df_raw.copy().iterrows():
|
|
|
159 |
row.sdk_version,
|
160 |
'sleep_time':
|
161 |
self.TO_TIME_STR[row.sleep_time],
|
162 |
+
'replicas':
|
163 |
+
self.add_div_tag_to_replicas(row.replicas),
|
164 |
}
|
165 |
new_rows.append(new_row)
|
166 |
df = pd.DataFrame(new_rows).loc[:, self.column_names]
|
style.css
CHANGED
@@ -65,3 +65,8 @@ div.hardware-cpu-upgrade {
|
|
65 |
div.hardware-cpu-basic {
|
66 |
color: deepskyblue;
|
67 |
}
|
|
|
|
|
|
|
|
|
|
|
|
65 |
div.hardware-cpu-basic {
|
66 |
color: deepskyblue;
|
67 |
}
|
68 |
+
|
69 |
+
/* set colors for replica */
|
70 |
+
div.multiple-replicas {
|
71 |
+
color: red;
|
72 |
+
}
|