Spaces:
Running
Running
admin
commited on
Commit
•
66f2b19
1
Parent(s):
343df62
upd flagging mode
Browse files
app.py
CHANGED
@@ -181,30 +181,28 @@ def activate(hf_users: str, ms_users: str):
|
|
181 |
if not ms_users:
|
182 |
ms_users = hf_users
|
183 |
|
|
|
184 |
hf_usernames = hf_users.split(";")
|
185 |
ms_usernames = ms_users.split(";")
|
186 |
-
spaces = []
|
187 |
for user in tqdm(hf_usernames, desc="Collecting spaces..."):
|
188 |
username = user.strip()
|
189 |
if username:
|
190 |
spaces += get_spaces(username)
|
191 |
time.sleep(DELAY)
|
192 |
|
193 |
-
monitors, studios = [], []
|
194 |
for space in spaces:
|
195 |
if "keep-spaces-active" in space:
|
196 |
monitors.append(space)
|
197 |
else:
|
198 |
studios.append(space)
|
199 |
-
spaces = monitors + studios
|
200 |
|
|
|
201 |
for user in tqdm(ms_usernames, desc="Collecting studios..."):
|
202 |
username = user.strip()
|
203 |
if username:
|
204 |
spaces += get_studios(username)
|
205 |
time.sleep(DELAY)
|
206 |
|
207 |
-
output = []
|
208 |
for space in tqdm(spaces, desc="Activating spaces..."):
|
209 |
output.append(
|
210 |
{
|
@@ -249,45 +247,48 @@ def listasks():
|
|
249 |
return "None"
|
250 |
|
251 |
|
252 |
-
|
253 |
-
gr.
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
|
|
|
|
|
|
|
181 |
if not ms_users:
|
182 |
ms_users = hf_users
|
183 |
|
184 |
+
spaces, monitors, studios, output = [], [], [], []
|
185 |
hf_usernames = hf_users.split(";")
|
186 |
ms_usernames = ms_users.split(";")
|
|
|
187 |
for user in tqdm(hf_usernames, desc="Collecting spaces..."):
|
188 |
username = user.strip()
|
189 |
if username:
|
190 |
spaces += get_spaces(username)
|
191 |
time.sleep(DELAY)
|
192 |
|
|
|
193 |
for space in spaces:
|
194 |
if "keep-spaces-active" in space:
|
195 |
monitors.append(space)
|
196 |
else:
|
197 |
studios.append(space)
|
|
|
198 |
|
199 |
+
spaces = monitors + studios
|
200 |
for user in tqdm(ms_usernames, desc="Collecting studios..."):
|
201 |
username = user.strip()
|
202 |
if username:
|
203 |
spaces += get_studios(username)
|
204 |
time.sleep(DELAY)
|
205 |
|
|
|
206 |
for space in tqdm(spaces, desc="Activating spaces..."):
|
207 |
output.append(
|
208 |
{
|
|
|
247 |
return "None"
|
248 |
|
249 |
|
250 |
+
if __name__ == "__main__":
|
251 |
+
with gr.Blocks() as demo:
|
252 |
+
gr.Interface(
|
253 |
+
title="Start keeping all spaces active periodically",
|
254 |
+
fn=monitor,
|
255 |
+
inputs=[
|
256 |
+
gr.Textbox(
|
257 |
+
label="HuggingFace",
|
258 |
+
placeholder="Usernames joint by ;",
|
259 |
+
),
|
260 |
+
gr.Textbox(
|
261 |
+
label="ModelScope",
|
262 |
+
placeholder="Usernames joint by ;",
|
263 |
+
),
|
264 |
+
],
|
265 |
+
outputs=None,
|
266 |
+
flagging_mode="never",
|
267 |
+
)
|
268 |
+
|
269 |
+
gr.Interface(
|
270 |
+
title="See current task status",
|
271 |
+
fn=listasks,
|
272 |
+
inputs=None,
|
273 |
+
outputs=gr.Textbox(label="Current task details"),
|
274 |
+
flagging_mode="never",
|
275 |
+
)
|
276 |
+
|
277 |
+
gr.Interface(
|
278 |
+
title="Test activation for all spaces once",
|
279 |
+
fn=activate,
|
280 |
+
inputs=[
|
281 |
+
gr.Textbox(
|
282 |
+
label="HuggingFace",
|
283 |
+
placeholder="Usernames joint by ;",
|
284 |
+
),
|
285 |
+
gr.Textbox(
|
286 |
+
label="ModelScope",
|
287 |
+
placeholder="Usernames joint by ;",
|
288 |
+
),
|
289 |
+
],
|
290 |
+
outputs=gr.Dataframe(label="Activated spaces"),
|
291 |
+
flagging_mode="never",
|
292 |
+
)
|
293 |
+
|
294 |
+
demo.launch()
|