davanstrien HF staff commited on
Commit
89ea3f0
1 Parent(s): 8ff5647

Add gradio functionality and dependencies

Browse files
Files changed (3) hide show
  1. app.py +25 -0
  2. requirements.in +3 -0
  3. requirements.txt +195 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from datetime import datetime
3
+ from apscheduler.schedulers.background import BackgroundScheduler
4
+ from huggingface_hub import restart_space
5
+ import os
6
+
7
+ HF_TOKEN = os.getenv("HF_TOKEN")
8
+
9
+ time_start = datetime.now()
10
+
11
+
12
+ def show_time():
13
+ return f"Time started: {time_start}"
14
+
15
+
16
+ def restart():
17
+ gr.Info("Restarting space...")
18
+ restart_space("davanstrien/restart", token=HF_TOKEN)
19
+
20
+
21
+ iface = gr.Interface(fn=show_time, inputs="text", outputs="text")
22
+ iface.launch()
23
+
24
+ scheduler = BackgroundScheduler()
25
+ job = scheduler.add_job(restart, "interval", minutes=2)
requirements.in ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ apscheduler
2
+ gradio
3
+ huggingface_hub
requirements.txt ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file was autogenerated by uv via the following command:
2
+ # uv pip compile requirements.in -o requirements.txt
3
+ aiofiles==23.2.1
4
+ # via gradio
5
+ altair==5.2.0
6
+ # via gradio
7
+ annotated-types==0.6.0
8
+ # via pydantic
9
+ anyio==4.3.0
10
+ # via
11
+ # httpx
12
+ # starlette
13
+ apscheduler==3.10.4
14
+ attrs==23.2.0
15
+ # via
16
+ # jsonschema
17
+ # referencing
18
+ certifi==2024.2.2
19
+ # via
20
+ # httpcore
21
+ # httpx
22
+ # requests
23
+ charset-normalizer==3.3.2
24
+ # via requests
25
+ click==8.1.7
26
+ # via
27
+ # typer
28
+ # uvicorn
29
+ colorama==0.4.6
30
+ # via typer
31
+ contourpy==1.2.0
32
+ # via matplotlib
33
+ cycler==0.12.1
34
+ # via matplotlib
35
+ fastapi==0.110.0
36
+ # via gradio
37
+ ffmpy==0.3.2
38
+ # via gradio
39
+ filelock==3.13.1
40
+ # via huggingface-hub
41
+ fonttools==4.50.0
42
+ # via matplotlib
43
+ fsspec==2024.3.1
44
+ # via
45
+ # gradio-client
46
+ # huggingface-hub
47
+ gradio==4.22.0
48
+ gradio-client==0.13.0
49
+ # via gradio
50
+ h11==0.14.0
51
+ # via
52
+ # httpcore
53
+ # uvicorn
54
+ httpcore==1.0.4
55
+ # via httpx
56
+ httpx==0.27.0
57
+ # via
58
+ # gradio
59
+ # gradio-client
60
+ huggingface-hub==0.21.4
61
+ # via
62
+ # gradio
63
+ # gradio-client
64
+ idna==3.6
65
+ # via
66
+ # anyio
67
+ # httpx
68
+ # requests
69
+ importlib-resources==6.4.0
70
+ # via gradio
71
+ jinja2==3.1.3
72
+ # via
73
+ # altair
74
+ # gradio
75
+ jsonschema==4.21.1
76
+ # via altair
77
+ jsonschema-specifications==2023.12.1
78
+ # via jsonschema
79
+ kiwisolver==1.4.5
80
+ # via matplotlib
81
+ markdown-it-py==3.0.0
82
+ # via rich
83
+ markupsafe==2.1.5
84
+ # via
85
+ # gradio
86
+ # jinja2
87
+ matplotlib==3.8.3
88
+ # via gradio
89
+ mdurl==0.1.2
90
+ # via markdown-it-py
91
+ numpy==1.26.4
92
+ # via
93
+ # altair
94
+ # contourpy
95
+ # gradio
96
+ # matplotlib
97
+ # pandas
98
+ orjson==3.9.15
99
+ # via gradio
100
+ packaging==24.0
101
+ # via
102
+ # altair
103
+ # gradio
104
+ # gradio-client
105
+ # huggingface-hub
106
+ # matplotlib
107
+ pandas==2.2.1
108
+ # via
109
+ # altair
110
+ # gradio
111
+ pillow==10.2.0
112
+ # via
113
+ # gradio
114
+ # matplotlib
115
+ pydantic==2.6.4
116
+ # via
117
+ # fastapi
118
+ # gradio
119
+ pydantic-core==2.16.3
120
+ # via pydantic
121
+ pydub==0.25.1
122
+ # via gradio
123
+ pygments==2.17.2
124
+ # via rich
125
+ pyparsing==3.1.2
126
+ # via matplotlib
127
+ python-dateutil==2.9.0.post0
128
+ # via
129
+ # matplotlib
130
+ # pandas
131
+ python-multipart==0.0.9
132
+ # via gradio
133
+ pytz==2024.1
134
+ # via
135
+ # apscheduler
136
+ # pandas
137
+ pyyaml==6.0.1
138
+ # via
139
+ # gradio
140
+ # huggingface-hub
141
+ referencing==0.34.0
142
+ # via
143
+ # jsonschema
144
+ # jsonschema-specifications
145
+ requests==2.31.0
146
+ # via huggingface-hub
147
+ rich==13.7.1
148
+ # via typer
149
+ rpds-py==0.18.0
150
+ # via
151
+ # jsonschema
152
+ # referencing
153
+ ruff==0.3.4
154
+ # via gradio
155
+ semantic-version==2.10.0
156
+ # via gradio
157
+ shellingham==1.5.4
158
+ # via typer
159
+ six==1.16.0
160
+ # via
161
+ # apscheduler
162
+ # python-dateutil
163
+ sniffio==1.3.1
164
+ # via
165
+ # anyio
166
+ # httpx
167
+ starlette==0.36.3
168
+ # via fastapi
169
+ tomlkit==0.12.0
170
+ # via gradio
171
+ toolz==0.12.1
172
+ # via altair
173
+ tqdm==4.66.2
174
+ # via huggingface-hub
175
+ typer==0.10.0
176
+ # via gradio
177
+ typing-extensions==4.10.0
178
+ # via
179
+ # fastapi
180
+ # gradio
181
+ # gradio-client
182
+ # huggingface-hub
183
+ # pydantic
184
+ # pydantic-core
185
+ # typer
186
+ tzdata==2024.1
187
+ # via pandas
188
+ tzlocal==5.2
189
+ # via apscheduler
190
+ urllib3==2.2.1
191
+ # via requests
192
+ uvicorn==0.29.0
193
+ # via gradio
194
+ websockets==11.0.3
195
+ # via gradio-client