Omnibus commited on
Commit
b278c94
·
verified ·
1 Parent(s): 8155b56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -40
app.py CHANGED
@@ -19,9 +19,9 @@ label.svelte-1mhtq7j.svelte-1mhtq7j.svelte-1mhtq7j {
19
  }
20
  """
21
 
22
- def show_s(name,token):
23
  spaces=[]
24
- spaces.append("")
25
 
26
  api = HfApi(token=token)
27
  author=name
@@ -30,7 +30,8 @@ def show_s(name,token):
30
  space_ea = space.id.split("/",1)[1]
31
  #s_info=api.space_info(f'{name}/{space}',files_metadata=True)
32
  #print(s_info)
33
- spaces.append(space_ea)
 
34
  #print (space_ea)
35
  return(gr.update(label="Spaces", choices=[s for s in spaces]))
36
  #gr.update(choices=[s for s in spaces],interactive=True))
@@ -122,7 +123,24 @@ def move(repo,space,dest,token):
122
  to_id=f'{dest}/{space}'
123
  move_repo(from_id=from_id,to_id=to_id,repo_type='space',token=token)
124
  print("REPO MOVED")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  with gr.Blocks(css=css) as build:
 
126
  with gr.Row(visible=False) as no:
127
  pass_box=gr.Textbox()
128
  pass_btn=gr.Button()
@@ -158,45 +176,17 @@ with gr.Blocks(css=css) as build:
158
  with gr.Row():
159
  dest=gr.Textbox(label="Destination")
160
  move_btn=gr.Button("Move Repo")
161
- '''
162
- with gr.Tab("View 2"):
163
- with gr.Row():
164
- with gr.Column(scale=2):
165
- with gr.Group():
166
- with gr.Row():
167
- s_name = gr.Dropdown(label="Spaces", choices=[])
168
- f_name = gr.Dropdown(label="Files", choices=[])
169
- with gr.Row():
170
- l_btn = gr.Button("Load Space")
171
  with gr.Row():
172
- show_all_btn1 = gr.Button("Load All 1",visible=False)
173
- show_all_btn2 = gr.Button("Load All 2",visible=False)
174
- uu=gr.Textbox(visible=False)
175
- file_frame=gr.HTML()
176
-
177
- with gr.Tab("View 3"):
178
- with gr.Row():
179
- with gr.Column(scale=1):
180
- with gr.Group():
181
- space_check=gr.CheckboxGroup(elem_id="my_checkbox",label="Spaces",choices=[])
182
- with gr.Column(scale=1):
183
- message_box=gr.HTML()
184
- with gr.Column(scale=1):
185
- dl_checked_btn=gr.Button("Download Checked")
186
- delete_checked_btn=gr.Button("Delete Checked")
187
- with gr.Row(visible=False) as sure_row:
188
- with gr.Column():
189
- ru_sure_box=gr.Textbox(label="type: 'CONFIRM' to confirm", value="")
190
- ru_sure_btn=gr.Button("Confirm Delete")
191
-
192
- with gr.Row():
193
- del_message_box=gr.HTML()
194
- gr.Column()
195
- sure_check=gr.Textbox(visible=False,value="")
196
- '''
197
 
198
- move_btn.click(move,[r_name,space_radio,dest,token]).then(show_s,[r_name,token],[space_radio])
199
- s_btn.click(show_s,[r_name,token],[space_radio])
 
 
 
 
200
  space_radio.change(show_f,[r_name,space_radio,token,tog],[files,file_radio,space_info_json])
201
  file_radio.change(show_f_cont,[r_name,space_radio,file_radio,token],[file_contents])
202
  build.queue(default_concurrency_limit=10).launch(show_api=False)
 
19
  }
20
  """
21
 
22
+ def show_s(name,token,save_list):
23
  spaces=[]
24
+ #spaces.append("")
25
 
26
  api = HfApi(token=token)
27
  author=name
 
30
  space_ea = space.id.split("/",1)[1]
31
  #s_info=api.space_info(f'{name}/{space}',files_metadata=True)
32
  #print(s_info)
33
+ if not space_ea in save_state:
34
+ spaces.append(space_ea)
35
  #print (space_ea)
36
  return(gr.update(label="Spaces", choices=[s for s in spaces]))
37
  #gr.update(choices=[s for s in spaces],interactive=True))
 
123
  to_id=f'{dest}/{space}'
124
  move_repo(from_id=from_id,to_id=to_id,repo_type='space',token=token)
125
  print("REPO MOVED")
126
+
127
+ def add_save(space,save_list):
128
+ this = True
129
+ for ea in save_list:
130
+ if space == ea:
131
+ this = False
132
+ if this:
133
+ save_list.append(space)
134
+ return gr.update(choices=[f for f in save_list],interactive=True)
135
+
136
+ def rem_save(space,save_list):
137
+ for ea in save_list:
138
+ if not space == ea:
139
+ save_list.append(space)
140
+ return gr.update(choices=[f for f in save_list],interactive=True)
141
+
142
  with gr.Blocks(css=css) as build:
143
+ save_state=gr.State()
144
  with gr.Row(visible=False) as no:
145
  pass_box=gr.Textbox()
146
  pass_btn=gr.Button()
 
176
  with gr.Row():
177
  dest=gr.Textbox(label="Destination")
178
  move_btn=gr.Button("Move Repo")
 
 
 
 
 
 
 
 
 
 
179
  with gr.Row():
180
+ save_list=gr.Radio(label="Protected",choices=[])
181
+ save_btn=gr.Button("Protect")
182
+ rem_btn=gr.Button("Remove")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
 
184
+ save_btn.click(add_save,[space_radio,save_list],save_list)
185
+ rem_btn.click(rem_save,[space_radio,save_list],save_list)
186
+
187
+ move_btn.click(move,[r_name,space_radio,dest,token]).then(show_s,[r_name,token,save_list],[space_radio])
188
+ s_btn.click(show_s,[r_name,token,save_list],[space_radio])
189
+
190
  space_radio.change(show_f,[r_name,space_radio,token,tog],[files,file_radio,space_info_json])
191
  file_radio.change(show_f_cont,[r_name,space_radio,file_radio,token],[file_contents])
192
  build.queue(default_concurrency_limit=10).launch(show_api=False)