Spaces:
Runtime error
Runtime error
Commit
·
4b3dc53
1
Parent(s):
65dd1ad
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
import requests
|
|
|
4 |
|
5 |
def avaliable_providers():
|
6 |
providers = []
|
@@ -159,6 +160,32 @@ def delete_endpoint(
|
|
159 |
else:
|
160 |
return f"something went wrong {response.status_code} = {response.text}"
|
161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
def update_endpoint(
|
163 |
hf_token_input,
|
164 |
endpoint_name_input,
|
@@ -201,7 +228,18 @@ with gr.Blocks() as demo2:
|
|
201 |
show_label=False,
|
202 |
type="password"
|
203 |
)
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
gr.Markdown(
|
206 |
"""
|
207 |
### <br><center style="color:green">(Deploy Your Model on 🤗 Endpoint)</center>
|
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
import requests
|
4 |
+
import pandas as pd
|
5 |
|
6 |
def avaliable_providers():
|
7 |
providers = []
|
|
|
160 |
else:
|
161 |
return f"something went wrong {response.status_code} = {response.text}"
|
162 |
|
163 |
+
def get_all_endpoints(
|
164 |
+
hf_token_input,
|
165 |
+
):
|
166 |
+
response = requests.get(
|
167 |
+
f"https://api.endpoints.huggingface.cloud/endpoint",
|
168 |
+
headers = {
|
169 |
+
"Authorization": f"Bearer {hf_token_input.strip()}",
|
170 |
+
"Content-Type": "application/json",
|
171 |
+
})
|
172 |
+
if response.status_code == 401:
|
173 |
+
return "Invalid token"
|
174 |
+
elif response.status_code == 200:
|
175 |
+
endpoints_json = response.json()
|
176 |
+
endpoints_df = pd.DataFrame(endpoints_json["items"])
|
177 |
+
endpoints_df = endpoints_df[["name", "model", "provider", "compute", "status"]]
|
178 |
+
endpoints_df["model"] = endpoints_df["model"].apply(lambda x: x["repository"] + "@" + x["revision"])
|
179 |
+
endpoints_df["provider"] = endpoints_df["provider"].apply(lambda x: x["vendor"] + "/" + x["region"])
|
180 |
+
endpoints_df["compute"] = endpoints_df["compute"].apply(lambda x: x["instanceType"] + "·" + x["instanceSize"] + " [" + x["accelerator"] + "]")
|
181 |
+
endpoints_df["status"] = endpoints_df["status"].apply(lambda x: x["state"])
|
182 |
+
endpoints_df["minReplica"] = endpoints_df["compute"].apply(lambda x: x["scaling"]["minReplica"])
|
183 |
+
endpoints_df["maxReplica"] = endpoints_df["compute"].apply(lambda x: x["scaling"]["maxReplica"])
|
184 |
+
endpoints_df["createdAt"] = endpoints_df["status"].apply(lambda x: x["createdAt"])
|
185 |
+
endpoints_df["updatedAt"] = endpoints_df["status"].apply(lambda x: x["updatedAt"])
|
186 |
+
endpoints_df = endpoints_df[["name", "model", "provider", "compute", "status", "minReplica", "maxReplica", "createdAt", "updatedAt"]]
|
187 |
+
return endpoints_df
|
188 |
+
|
189 |
def update_endpoint(
|
190 |
hf_token_input,
|
191 |
endpoint_name_input,
|
|
|
228 |
show_label=False,
|
229 |
type="password"
|
230 |
)
|
231 |
+
gr.Markdown("""
|
232 |
+
### All Running Endpoints
|
233 |
+
""")
|
234 |
+
|
235 |
+
endpoints_table = gr.DataTable(
|
236 |
+
columns=["Endpoint Name", "Revision", "Provider", "Instance Type", "Status", "Min Replica", "Max Replica", "Created At", "Updated At"],
|
237 |
+
rows=[],
|
238 |
+
editable=False,
|
239 |
+
)
|
240 |
+
info_button = gr.Button(value="Get Info")
|
241 |
+
info_button.change(get_all_endpoints, inputs=hf_token_input, outputs=endpoints_table)
|
242 |
+
|
243 |
gr.Markdown(
|
244 |
"""
|
245 |
### <br><center style="color:green">(Deploy Your Model on 🤗 Endpoint)</center>
|