Spaces:
Sleeping
Sleeping
Update dl.py
Browse files
dl.py
CHANGED
|
@@ -270,6 +270,19 @@ def get_space_runtime(author,checklist,token):
|
|
| 270 |
outp=api.get_space_runtime(f'{author}/{space}')
|
| 271 |
space_info.append(outp['stage'])
|
| 272 |
return space_info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
def checkp(p):
|
| 274 |
if p == o:
|
| 275 |
return gr.update(visible=False), gr.update(visible=True)
|
|
@@ -328,16 +341,30 @@ with gr.Blocks(css=css) as build:
|
|
| 328 |
with gr.Group():
|
| 329 |
space_check=gr.CheckboxGroup(elem_id="my_checkbox",label="Spaces",choices=[])
|
| 330 |
with gr.Column(scale=1):
|
| 331 |
-
|
| 332 |
-
checkboxes=[]
|
| 333 |
-
for i in range(max_checks):
|
| 334 |
-
t = gr.CheckboxGroup(choices=["Delete","Private"],visible=False)
|
| 335 |
-
checkboxes.append(t)
|
| 336 |
with gr.Column(scale=1):
|
| 337 |
dl_checked_btn=gr.Button("Download Checked")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
gr.Column()
|
| 339 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 340 |
dl_checked_btn.click(dl_checked_fn,[r_name,space_check,token],files)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
|
| 342 |
show_all_btn1.click(show_all,[r_name,token],files)
|
| 343 |
show_all_btn2.click(show_all_z,[r_name,token],files)
|
|
|
|
| 270 |
outp=api.get_space_runtime(f'{author}/{space}')
|
| 271 |
space_info.append(outp['stage'])
|
| 272 |
return space_info
|
| 273 |
+
def delete_checked(confirm_val,author,checklist,token):
|
| 274 |
+
if confirm_val=="DELETE":
|
| 275 |
+
api = HfApi(token=token)
|
| 276 |
+
s_ist = checklist
|
| 277 |
+
delete_list = []
|
| 278 |
+
for i,space_ea in enumerate(s_ist):
|
| 279 |
+
|
| 280 |
+
api.delete_repo(f'{author}/{space_ea}')
|
| 281 |
+
delete_list.append(f'Deleted:: {space_ea}\n')
|
| 282 |
+
yield delete_list,gr.update(visible=False)
|
| 283 |
+
else:
|
| 284 |
+
yield "Not Deleting", gr.update(visible=False)
|
| 285 |
+
|
| 286 |
def checkp(p):
|
| 287 |
if p == o:
|
| 288 |
return gr.update(visible=False), gr.update(visible=True)
|
|
|
|
| 341 |
with gr.Group():
|
| 342 |
space_check=gr.CheckboxGroup(elem_id="my_checkbox",label="Spaces",choices=[])
|
| 343 |
with gr.Column(scale=1):
|
| 344 |
+
message_box=gr.HTML()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
with gr.Column(scale=1):
|
| 346 |
dl_checked_btn=gr.Button("Download Checked")
|
| 347 |
+
delete_checked_btn=gr.Button("Delete Checked")
|
| 348 |
+
with gr.Row(visible=False) as sure_row:
|
| 349 |
+
ru_sure_box=gr.Textbox(label="type: 'CONFIRM' to confirm", value="")
|
| 350 |
+
ru_sure_btn=gr.Button("Confirm Delete")
|
| 351 |
gr.Column()
|
| 352 |
+
sure_check=gr.Textbox(visible=False,value="")
|
| 353 |
+
|
| 354 |
+
def ru_sure_fn():
|
| 355 |
+
return gr.update(label="type: 'DELETE' to confirm",visible=True)
|
| 356 |
+
|
| 357 |
+
def update_checked_message(inp):
|
| 358 |
+
html=""
|
| 359 |
+
for ea in inp:
|
| 360 |
+
html=f'{html}<br>{ea}'
|
| 361 |
+
return html
|
| 362 |
dl_checked_btn.click(dl_checked_fn,[r_name,space_check,token],files)
|
| 363 |
+
delete_checked_btn.click(ru_sure_fn,None,ru_sure_row)
|
| 364 |
+
ru_sure_btn.click(delete_checked,[ru_sure_box,r_name,space_check,token],[message_box,sure_row])
|
| 365 |
+
|
| 366 |
+
space_check.change(update_checked_message,)
|
| 367 |
+
|
| 368 |
|
| 369 |
show_all_btn1.click(show_all,[r_name,token],files)
|
| 370 |
show_all_btn2.click(show_all_z,[r_name,token],files)
|