JustAnotherCibrarian commited on
Commit
6489caf
·
verified ·
1 Parent(s): 0264473

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -29
app.py CHANGED
@@ -102,26 +102,48 @@ with gr.Blocks(title="HF Repo Access Manager") as demo:
102
  scale=0,
103
  min_width=40
104
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
- with gr.Row():
107
- with gr.Column():
108
- multi_repo_input = gr.Dropdown(
109
- label="Repositories to grant",
110
- multiselect=True,
111
- allow_custom_value=True, # Can type other people's repos.
112
- interactive=True,
113
- choices=[DUMMY_REFRESH],
114
- value=[],
115
- info="Username/repo-name"
116
- )
117
- multi_user_input = gr.Textbox(
118
- label="User/Organization",
119
- placeholder="username-or-org-name"
120
- )
121
- multi_btn = gr.Button("Grant Access to All", variant="primary")
122
-
123
- with gr.Column():
124
- multi_output = gr.Textbox(label="Results", lines=10)
 
125
 
126
  # ---Actions---
127
 
@@ -150,12 +172,13 @@ with gr.Blocks(title="HF Repo Access Manager") as demo:
150
  Lambda method doesn't seem to work for some reason,
151
  perhaps profile and oauth aren't functional with args/kwargs.
152
  """
153
- return refresh_all_data(username, token, force = True)
 
154
 
155
  refresh_repos_btn.click(
156
  fn=force_refresh,
157
  inputs=[hf_user, hf_token],
158
- outputs=[multi_repo_input]
159
  )
160
 
161
  def check_dummy(username, token, dropdown_value = None):
@@ -177,17 +200,27 @@ with gr.Blocks(title="HF Repo Access Manager") as demo:
177
  return refresh_all_data(username, token, indwild = True)
178
  return gr.Dropdown()
179
 
180
- # Dummy load only.
181
- multi_repo_input.change(
182
  fn=check_dummy,
183
- inputs=[hf_user, hf_token, multi_repo_input],
184
- outputs=[multi_repo_input]
185
  )
186
-
187
- multi_btn.click(
 
 
 
 
 
 
 
 
 
 
188
  fn=grant_access_multiple_repos,
189
- inputs=[hf_token, multi_repo_input, multi_user_input],
190
- outputs=multi_output
191
  )
192
 
193
  if __name__ == "__main__":
 
102
  scale=0,
103
  min_width=40
104
  )
105
+
106
+ with gr.Tab("Request access"):
107
+ with gr.Row():
108
+ with gr.Column():
109
+ req_repo_input = gr.Dropdown(
110
+ label="Repositories to request",
111
+ multiselect=True,
112
+ allow_custom_value=True, # Can type other people's repos.
113
+ interactive=True,
114
+ choices=[DUMMY_REFRESH],
115
+ value=[],
116
+ info="Username/repo-name"
117
+ )
118
+ req_user_input = gr.Textbox(
119
+ label="User/Organization",
120
+ placeholder="username-or-org-name"
121
+ )
122
+ req_btn = gr.Button("Request access", variant="primary")
123
+
124
+ with gr.Column():
125
+ req_output = gr.Textbox(label="Results", lines=10)
126
 
127
+ with gr.Tab("Grant access"):
128
+ with gr.Row():
129
+ with gr.Column():
130
+ gra_repo_input = gr.Dropdown(
131
+ label="Repositories to grant",
132
+ multiselect=True,
133
+ allow_custom_value=True, # Can type other people's repos.
134
+ interactive=True,
135
+ choices=[DUMMY_REFRESH],
136
+ value=[],
137
+ info="Username/repo-name"
138
+ )
139
+ gra_user_input = gr.Textbox(
140
+ label="User/Organization",
141
+ placeholder="username-or-org-name"
142
+ )
143
+ gra_btn = gr.Button("Grant access", variant="primary")
144
+
145
+ with gr.Column():
146
+ gra_output = gr.Textbox(label="Results", lines=10)
147
 
148
  # ---Actions---
149
 
 
172
  Lambda method doesn't seem to work for some reason,
173
  perhaps profile and oauth aren't functional with args/kwargs.
174
  """
175
+ dropbear = refresh_all_data(username, token, force = True)
176
+ return (dropbear, dropbear)
177
 
178
  refresh_repos_btn.click(
179
  fn=force_refresh,
180
  inputs=[hf_user, hf_token],
181
+ outputs=[req_repo_input, gra_repo_input]
182
  )
183
 
184
  def check_dummy(username, token, dropdown_value = None):
 
200
  return refresh_all_data(username, token, indwild = True)
201
  return gr.Dropdown()
202
 
203
+ # Dummy + wild load only.
204
+ req_repo_input.change(
205
  fn=check_dummy,
206
+ inputs=[hf_user, hf_token, req_repo_input],
207
+ outputs=[req_repo_input]
208
  )
209
+ gra_repo_input.change(
210
+ fn=check_dummy,
211
+ inputs=[hf_user, hf_token, gra_repo_input],
212
+ outputs=[gra_repo_input]
213
+ )
214
+
215
+ req_btn.click(
216
+ fn=grant_access_multiple_repos,
217
+ inputs=[hf_token, req_repo_input, req_user_input],
218
+ outputs=req_output
219
+ )
220
+ gra_btn.click(
221
  fn=grant_access_multiple_repos,
222
+ inputs=[hf_token, gra_repo_input, gra_user_input],
223
+ outputs=gra_output
224
  )
225
 
226
  if __name__ == "__main__":