Omnibus commited on
Commit
6205933
1 Parent(s): 5561106

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py CHANGED
@@ -178,6 +178,32 @@ def set_space_visible(r_name,check_list,private_bool,token):
178
  private=private_bool,
179
  token=token,
180
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  with gr.Blocks(css=css) as build:
182
  save_state=gr.State()
183
  space_list=gr.State([])
@@ -229,11 +255,20 @@ with gr.Blocks(css=css) as build:
229
  check_list=gr.CheckboxGroup(choices=[])
230
  com_off = gr.Button("Turn OFF Commenting")
231
  com_on = gr.Button("Turn ON Commenting")
 
 
 
 
 
 
 
232
 
233
 
234
 
235
 
236
 
 
 
237
  com_off.click(toggle_comments_off, [r_name,check_list,token])
238
 
239
  save_btn.click(add_save,[space_radio,save_state],[save_state,save_list]).then(show_s,[r_name,token,save_state],[space_radio,check_list])
 
178
  private=private_bool,
179
  token=token,
180
  )
181
+
182
+ def load_space_status(r_name,token):
183
+ api = HfApi(token=token)
184
+ s_ist = (api.list_spaces(author=r_name))
185
+ tt=False
186
+ print(dir(s_ist[0]))
187
+ out_html="<td><tr><th>Name</th><th>Status</th></tr>"
188
+ for i,space in enumerate(s_ist):
189
+ space_ea = space.id.split("/",1)[1]
190
+ print(space.id)
191
+ out_html+=f'<tr><td>{space.id}</td><td>{space.id}</td></tr>'
192
+ out_html+="</td>"
193
+ return out_html
194
+ def rebuild_space(r_name,token):
195
+ api = HfApi(token=token)
196
+ s_ist = (api.list_spaces(author=r_name))
197
+ tt=False
198
+ for i,space in enumerate(s_ist):
199
+ space_ea = space.id.split("/",1)[1]
200
+ print(space.id)
201
+ if tt:
202
+ api.restart_space(
203
+ repo_id=f'{r_name}/{space_ea}',
204
+ token=token,
205
+ )
206
+ print(dir(s_ist[0]))
207
  with gr.Blocks(css=css) as build:
208
  save_state=gr.State()
209
  space_list=gr.State([])
 
255
  check_list=gr.CheckboxGroup(choices=[])
256
  com_off = gr.Button("Turn OFF Commenting")
257
  com_on = gr.Button("Turn ON Commenting")
258
+ with gr.Tab("All"):
259
+ with gr.Row():
260
+ with gr.Column():
261
+ load_spaces=gr.Button("Load Spaces")
262
+ with gr.Column():
263
+ refresh_btn=gr.Button("Rebuild")
264
+ space_status=gr.HTML()
265
 
266
 
267
 
268
 
269
 
270
+ load_spaces.click(load_space_status, [r_name,token],space_status)
271
+ refresh_btn.click(rebuild_space, [r_name,token])
272
  com_off.click(toggle_comments_off, [r_name,check_list,token])
273
 
274
  save_btn.click(add_save,[space_radio,save_state],[save_state,save_list]).then(show_s,[r_name,token,save_state],[space_radio,check_list])