Omnibus commited on
Commit
b34325a
·
1 Parent(s): f8d5fc8

Update dl.py

Browse files
Files changed (1) hide show
  1. dl.py +33 -19
dl.py CHANGED
@@ -43,6 +43,7 @@ def show_f(repo,name,token):
43
  print (f_ist)
44
  file_list = []
45
  #file_out = []
 
46
  if not os.path.exists(name):
47
  os.makedirs(name)
48
  for d_app in f_ist:
@@ -88,15 +89,8 @@ def show_f(repo,name,token):
88
  zipObj.write(f'{name}/{file}')
89
  file_list.append(f'{name}.zip')
90
 
91
- runtime_json=api.get_space_runtime(f'{repo}/{name}')
92
- print(dir(runtime_json))
93
- print(runtime_json.hardware)
94
- print(runtime_json.raw)
95
- print(runtime_json.requested_hardware)
96
- print(runtime_json.sleep_time)
97
- print(runtime_json.stage)
98
- print(runtime_json.storage)
99
-
100
  with open(f'{uid}-tmp.json','w') as f:
101
  json.dump(runtime_json.raw,f,indent=4)
102
  f.close()
@@ -104,8 +98,7 @@ def show_f(repo,name,token):
104
  return(gr.Dropdown.update(label="Files", choices=[f for f in f_ist],interactive=True),
105
  file_list,
106
  gr.update(choices=[f for f in f_ist],interactive=True),
107
- api.space_info(f'{repo}/{name}',files_metadata=True),
108
- runtime_json)
109
 
110
  def show_f2(repo,name,token):
111
  api = HfApi(token=token)
@@ -300,10 +293,10 @@ with gr.Blocks(css=css) as build:
300
  space_radio=gr.Radio(label="Spaces",choices=[])
301
  with gr.Column(scale=3):
302
  with gr.Tab("Space Info"):
303
- with gr.Column(scale=1):
304
- space_runtime_json=gr.JSON()
305
- with gr.Column(scale=3):
306
- space_info_json=gr.JSON()
307
  with gr.Tab("Files"):
308
  with gr.Column(scale=1):
309
  file_radio=gr.Radio(label="Files",choices=[])
@@ -332,10 +325,14 @@ with gr.Blocks(css=css) as build:
332
  with gr.Column(scale=1):
333
  with gr.Group():
334
  space_check=gr.CheckboxGroup(elem_id="my_checkbox",label="Spaces",choices=[])
 
 
 
 
 
335
  with gr.Column(scale=1):
336
  dl_checked_btn=gr.Button("Download Checked")
337
- with gr.Column(scale=2):
338
- file_contents_2=gr.HTML()
339
 
340
  dl_checked_btn.click(dl_checked_fn,[r_name,space_check,token],files)
341
 
@@ -347,9 +344,26 @@ with gr.Blocks(css=css) as build:
347
  f_name.change(show_f_cont,[r_name,s_name,f_name],[r_h])
348
 
349
  #s_name.change(show_f,[r_name,s_name,token],[d_app,files])
350
- space_radio.change(show_f,[r_name,space_radio,token],[f_name, files,file_radio,space_info_json,space_runtime_json])
351
  file_radio.change(show_f_cont,[r_name,space_radio,file_radio,token],[file_contents])
352
 
353
  pass_btn.click(checkp,pass_box,[no,yes])
354
  #inbut.click(build_space,[token,t_name,s_type,m_type,r_type,d_app,d_css],output_html)
355
- build.queue(concurrency_count=10).launch(show_api=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  print (f_ist)
44
  file_list = []
45
  #file_out = []
46
+
47
  if not os.path.exists(name):
48
  os.makedirs(name)
49
  for d_app in f_ist:
 
89
  zipObj.write(f'{name}/{file}')
90
  file_list.append(f'{name}.zip')
91
 
92
+ s_info=api.space_info(f'{repo}/{name}',files_metadata=True)
93
+ for ea in
 
 
 
 
 
 
 
94
  with open(f'{uid}-tmp.json','w') as f:
95
  json.dump(runtime_json.raw,f,indent=4)
96
  f.close()
 
98
  return(gr.Dropdown.update(label="Files", choices=[f for f in f_ist],interactive=True),
99
  file_list,
100
  gr.update(choices=[f for f in f_ist],interactive=True),
101
+ s_info)
 
102
 
103
  def show_f2(repo,name,token):
104
  api = HfApi(token=token)
 
293
  space_radio=gr.Radio(label="Spaces",choices=[])
294
  with gr.Column(scale=3):
295
  with gr.Tab("Space Info"):
296
+ with gr.Row():
297
+ with gr.Column(scale=3):
298
+ space_runtime_json=gr.JSON()
299
+ gr.Column(scale=1)
300
  with gr.Tab("Files"):
301
  with gr.Column(scale=1):
302
  file_radio=gr.Radio(label="Files",choices=[])
 
325
  with gr.Column(scale=1):
326
  with gr.Group():
327
  space_check=gr.CheckboxGroup(elem_id="my_checkbox",label="Spaces",choices=[])
328
+ with gr.Column(scale=1):
329
+ checkboxes=[]
330
+ for i in range(max_checks):
331
+ t = gr.CheckboxGroup(choices=["Delete","Private"],visible=False)
332
+ checkboxes.append(t)
333
  with gr.Column(scale=1):
334
  dl_checked_btn=gr.Button("Download Checked")
335
+ gr.Column()
 
336
 
337
  dl_checked_btn.click(dl_checked_fn,[r_name,space_check,token],files)
338
 
 
344
  f_name.change(show_f_cont,[r_name,s_name,f_name],[r_h])
345
 
346
  #s_name.change(show_f,[r_name,s_name,token],[d_app,files])
347
+ space_radio.change(show_f,[r_name,space_radio,token],[f_name, files,file_radio,space_info_json])
348
  file_radio.change(show_f_cont,[r_name,space_radio,file_radio,token],[file_contents])
349
 
350
  pass_btn.click(checkp,pass_box,[no,yes])
351
  #inbut.click(build_space,[token,t_name,s_type,m_type,r_type,d_app,d_css],output_html)
352
+ build.queue(concurrency_count=10).launch(show_api=False)
353
+
354
+
355
+ '''
356
+ max_textboxes = 10
357
+
358
+ def variable_outputs(k):
359
+ k = int(k)
360
+ return [gr.Textbox(visible=True)]*k + [gr.Textbox(visible=False)]*(max_textboxes-k)
361
+
362
+ with gr.Blocks() as demo:
363
+ s = gr.Slider(1, max_textboxes, value=max_textboxes, step=1, label="How many textboxes to show:")
364
+ textboxes = []
365
+ for i in range(max_textboxes):
366
+ t = gr.Textbox(f"Textbox {i}")
367
+ textboxes.append(t)
368
+
369
+ s.change(variable_outputs, s, textboxes)'''