Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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.
|
| 107 |
-
with gr.
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
| 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 |
-
|
|
|
|
| 154 |
|
| 155 |
refresh_repos_btn.click(
|
| 156 |
fn=force_refresh,
|
| 157 |
inputs=[hf_user, hf_token],
|
| 158 |
-
outputs=[
|
| 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 |
-
|
| 182 |
fn=check_dummy,
|
| 183 |
-
inputs=[hf_user, hf_token,
|
| 184 |
-
outputs=[
|
| 185 |
)
|
| 186 |
-
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
fn=grant_access_multiple_repos,
|
| 189 |
-
inputs=[hf_token,
|
| 190 |
-
outputs=
|
| 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__":
|