admin commited on
Commit
66f2b19
1 Parent(s): 343df62

upd flagging mode

Browse files
Files changed (1) hide show
  1. app.py +47 -46
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
- with gr.Blocks() as demo:
253
- gr.Interface(
254
- title="Start keeping all spaces active periodically",
255
- fn=monitor,
256
- inputs=[
257
- gr.Textbox(
258
- label="HuggingFace",
259
- placeholder="Usernames joint by ;",
260
- ),
261
- gr.Textbox(
262
- label="ModelScope",
263
- placeholder="Usernames joint by ;",
264
- ),
265
- ],
266
- outputs=None,
267
- allow_flagging="never",
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
- allow_flagging="never",
275
- )
276
- gr.Interface(
277
- title="Test activation for all spaces once",
278
- fn=activate,
279
- inputs=[
280
- gr.Textbox(
281
- label="HuggingFace",
282
- placeholder="Usernames joint by ;",
283
- ),
284
- gr.Textbox(
285
- label="ModelScope",
286
- placeholder="Usernames joint by ;",
287
- ),
288
- ],
289
- outputs=gr.Dataframe(label="Activated spaces"),
290
- allow_flagging="never",
291
- )
292
-
293
- demo.launch()
 
 
 
 
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()