Omnibus commited on
Commit
11fd631
1 Parent(s): 8906a0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -11
app.py CHANGED
@@ -248,22 +248,32 @@ def dl_checked_fn(author,checklist,token):
248
  def get_space_runtime(author,token):
249
  api=HfApi(token=token)
250
  space_info=[]
 
 
 
 
 
251
  api = HfApi(token=token)
252
  s_list = (api.list_spaces(author=author))
253
  for i,space in enumerate(s_list):
 
254
  try:
255
- print (f'SPACE :: {space}')
256
- #space_ea = space.id.split("/",1)[1]
257
  outr=api.get_space_runtime(f'{space.id}')
258
- print(f'OUTR :: {outr}')
259
- print (f'STAGE :: {outr.stage}')
260
- space_info.append(outr.stage)
 
 
 
 
 
 
 
261
  except Exception as e:
262
  print (e)
263
  pass
264
-
265
- print(space_info)
266
- #return space_info
267
 
268
 
269
  def delete_checked(confirm_val,author,checklist,token):
@@ -358,8 +368,12 @@ with gr.Blocks(css=css) as build:
358
  del_message_box=gr.HTML()
359
  gr.Column()
360
  sure_check=gr.Textbox(visible=False,value="")
361
-
362
-
 
 
 
 
363
 
364
  dl_checked_btn.click(dl_checked_fn,[r_name,space_check,token],files)
365
  delete_checked_btn.click(ru_sure_fn,None,sure_row)
@@ -371,7 +385,7 @@ with gr.Blocks(css=css) as build:
371
  show_all_btn1.click(show_all,[r_name,token],files)
372
  show_all_btn2.click(show_all_z,[r_name,token],files)
373
 
374
- s_btn.click(show_spaces,[r_name,token],[s_name,space_radio,space_check]).then(get_space_runtime,[r_name,token],None)
375
  l_btn.click(show_files,[r_name,s_name,token], [f_name, files,file_radio])
376
  f_name.change(show_f_frame,[r_name,s_name,f_name],[file_frame])
377
 
 
248
  def get_space_runtime(author,token):
249
  api=HfApi(token=token)
250
  space_info=[]
251
+ running=[]
252
+ runtime_error=[]
253
+ stopped=[]
254
+ paused=[]
255
+ no_app_file=[]
256
  api = HfApi(token=token)
257
  s_list = (api.list_spaces(author=author))
258
  for i,space in enumerate(s_list):
259
+ print(space)
260
  try:
261
+ space_name=space.split("/",1)[1]
 
262
  outr=api.get_space_runtime(f'{space.id}')
263
+ if outr.stage=="RUNNING":
264
+ running.append(space_name)
265
+ if outr.stage=="STOPPED":
266
+ stopped.append(space_name)
267
+ if outr.stage=="RUNTIME_ERROR":
268
+ runtime_error.append(space_name)
269
+ if outr.stage=="PAUSED":
270
+ paused.append(space_name)
271
+ if outr.stage=="NO_APP_FILE":
272
+ no_app_file.append(space_name)
273
  except Exception as e:
274
  print (e)
275
  pass
276
+ return running,runtime_error,stopped,paused,no_app_file
 
 
277
 
278
 
279
  def delete_checked(confirm_val,author,checklist,token):
 
368
  del_message_box=gr.HTML()
369
  gr.Column()
370
  sure_check=gr.Textbox(visible=False,value="")
371
+ with gr.Row():
372
+ running_json=gr.JSON()
373
+ runtime_error_json=gr.JSON()
374
+ stopped_json=gr.JSON()
375
+ paused_json=gr.JSON()
376
+ no_app_files_json=gr.JSON()
377
 
378
  dl_checked_btn.click(dl_checked_fn,[r_name,space_check,token],files)
379
  delete_checked_btn.click(ru_sure_fn,None,sure_row)
 
385
  show_all_btn1.click(show_all,[r_name,token],files)
386
  show_all_btn2.click(show_all_z,[r_name,token],files)
387
 
388
+ s_btn.click(show_spaces,[r_name,token],[s_name,space_radio,space_check]).then(get_space_runtime,[r_name,token],[running_json,runtime_error_json,stopped_json,paused_json,no_app_files_json])
389
  l_btn.click(show_files,[r_name,s_name,token], [f_name, files,file_radio])
390
  f_name.change(show_f_frame,[r_name,s_name,f_name],[file_frame])
391