Spaces:
Runtime error
Runtime error
Update
Browse files- app.py +12 -17
- demo_list.py +4 -7
- requirements.txt +1 -0
- style.css +2 -6
app.py
CHANGED
@@ -2,32 +2,27 @@
|
|
2 |
|
3 |
from __future__ import annotations
|
4 |
|
|
|
|
|
5 |
import gradio as gr
|
6 |
-
|
|
|
7 |
|
8 |
from demo_list import DemoList
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
DEFAULT_COLUMNS = [
|
13 |
-
'title',
|
14 |
-
'arxiv',
|
15 |
-
'likes',
|
16 |
-
'tags',
|
17 |
-
'status',
|
18 |
-
'hardware',
|
19 |
-
]
|
20 |
|
|
|
|
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
26 |
|
27 |
with gr.Blocks(css='style.css') as demo:
|
28 |
df = gr.Dataframe(value=demo_list.df,
|
29 |
datatype=demo_list.column_datatype,
|
30 |
type='pandas')
|
31 |
-
refresh_button = gr.Button('Refresh')
|
32 |
-
refresh_button.click(fn=update_df, outputs=df)
|
33 |
demo.queue(api_open=False).launch()
|
|
|
2 |
|
3 |
from __future__ import annotations
|
4 |
|
5 |
+
import os
|
6 |
+
|
7 |
import gradio as gr
|
8 |
+
from apscheduler.schedulers.background import BackgroundScheduler
|
9 |
+
from huggingface_hub import HfApi
|
10 |
|
11 |
from demo_list import DemoList
|
12 |
|
13 |
+
INTERVAL_MIN = int(os.getenv('INTERVAL_MIN', '10'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
demo_list = DemoList()
|
16 |
+
api = HfApi()
|
17 |
|
18 |
+
scheduler = BackgroundScheduler()
|
19 |
+
scheduler.add_job(func=lambda: api.restart_space('hysts/list-of-demos'),
|
20 |
+
trigger='interval',
|
21 |
+
seconds=60 * INTERVAL_MIN)
|
22 |
+
scheduler.start()
|
23 |
|
24 |
with gr.Blocks(css='style.css') as demo:
|
25 |
df = gr.Dataframe(value=demo_list.df,
|
26 |
datatype=demo_list.column_datatype,
|
27 |
type='pandas')
|
|
|
|
|
28 |
demo.queue(api_open=False).launch()
|
demo_list.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import copy
|
2 |
import datetime
|
3 |
import operator
|
4 |
-
import os
|
5 |
import pathlib
|
6 |
|
7 |
import pandas as pd
|
@@ -11,8 +10,6 @@ from huggingface_hub import HfApi
|
|
11 |
|
12 |
repo_dir = pathlib.Path(__file__).parent
|
13 |
|
14 |
-
HF_TOKEN = os.getenv('HF_TOKEN')
|
15 |
-
|
16 |
|
17 |
class DemoList:
|
18 |
COLUMN_INFO = [
|
@@ -31,7 +28,7 @@ class DemoList:
|
|
31 |
]
|
32 |
|
33 |
def __init__(self):
|
34 |
-
self.api = HfApi(
|
35 |
self.data = self.load_data()
|
36 |
self.df = self.to_df()
|
37 |
|
@@ -98,7 +95,7 @@ class DemoList:
|
|
98 |
if status == 'RUNNING':
|
99 |
color = 'green'
|
100 |
elif status in ['STOPPED', 'PAUSED']:
|
101 |
-
color = '
|
102 |
elif status in ['RUNTIME_ERROR', 'BUILD_ERROR']:
|
103 |
color = 'red'
|
104 |
else:
|
@@ -109,7 +106,7 @@ class DemoList:
|
|
109 |
if sdk == 'gradio':
|
110 |
color = 'orange'
|
111 |
elif sdk == 'docker':
|
112 |
-
color = '
|
113 |
else:
|
114 |
color = ''
|
115 |
return f'<div class="{color}">{sdk}</div>'
|
@@ -121,7 +118,7 @@ class DemoList:
|
|
121 |
if 't4' in hardware or 'a10g' in hardware or 'a100' in hardware:
|
122 |
color = 'red'
|
123 |
elif suggested_hardware and 'cpu' not in suggested_hardware:
|
124 |
-
color = '
|
125 |
else:
|
126 |
return hardware
|
127 |
return f'<div class="{color}">{hardware}</div>'
|
|
|
1 |
import copy
|
2 |
import datetime
|
3 |
import operator
|
|
|
4 |
import pathlib
|
5 |
|
6 |
import pandas as pd
|
|
|
10 |
|
11 |
repo_dir = pathlib.Path(__file__).parent
|
12 |
|
|
|
|
|
13 |
|
14 |
class DemoList:
|
15 |
COLUMN_INFO = [
|
|
|
28 |
]
|
29 |
|
30 |
def __init__(self):
|
31 |
+
self.api = HfApi()
|
32 |
self.data = self.load_data()
|
33 |
self.df = self.to_df()
|
34 |
|
|
|
95 |
if status == 'RUNNING':
|
96 |
color = 'green'
|
97 |
elif status in ['STOPPED', 'PAUSED']:
|
98 |
+
color = 'orange'
|
99 |
elif status in ['RUNTIME_ERROR', 'BUILD_ERROR']:
|
100 |
color = 'red'
|
101 |
else:
|
|
|
106 |
if sdk == 'gradio':
|
107 |
color = 'orange'
|
108 |
elif sdk == 'docker':
|
109 |
+
color = 'deepskyblue'
|
110 |
else:
|
111 |
color = ''
|
112 |
return f'<div class="{color}">{sdk}</div>'
|
|
|
118 |
if 't4' in hardware or 'a10g' in hardware or 'a100' in hardware:
|
119 |
color = 'red'
|
120 |
elif suggested_hardware and 'cpu' not in suggested_hardware:
|
121 |
+
color = 'deepskyblue'
|
122 |
else:
|
123 |
return hardware
|
124 |
return f'<div class="{color}">{hardware}</div>'
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
gradio==3.36.1
|
2 |
huggingface-hub==0.16.4
|
3 |
pandas==2.0.2
|
|
|
1 |
+
apscheduler==3.10.1
|
2 |
gradio==3.36.1
|
3 |
huggingface-hub==0.16.4
|
4 |
pandas==2.0.2
|
style.css
CHANGED
@@ -22,16 +22,12 @@ div.green {
|
|
22 |
color: green;
|
23 |
}
|
24 |
|
25 |
-
div.yellow {
|
26 |
-
color: yellow;
|
27 |
-
}
|
28 |
-
|
29 |
div.red {
|
30 |
color: red;
|
31 |
}
|
32 |
|
33 |
-
div.
|
34 |
-
color:
|
35 |
}
|
36 |
|
37 |
div.orange {
|
|
|
22 |
color: green;
|
23 |
}
|
24 |
|
|
|
|
|
|
|
|
|
25 |
div.red {
|
26 |
color: red;
|
27 |
}
|
28 |
|
29 |
+
div.deepskyblue {
|
30 |
+
color: deepskyblue;
|
31 |
}
|
32 |
|
33 |
div.orange {
|