Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -183,7 +183,7 @@ def submit(
|
|
183 |
type = compute_resources[-1].strip()
|
184 |
|
185 |
payload = {
|
186 |
-
"accountId":
|
187 |
"compute": {
|
188 |
"accelerator": accelerator,
|
189 |
"instanceSize": size[1:],
|
@@ -202,7 +202,7 @@ def submit(
|
|
202 |
"revision": head_sha,
|
203 |
"task": task_selector.lower()
|
204 |
},
|
205 |
-
"name": endpoint_name_input,
|
206 |
"provider": {
|
207 |
"region": region_selector.split("/")[0].lower(),
|
208 |
"vendor": provider_selector.lower()
|
@@ -215,6 +215,24 @@ def submit(
|
|
215 |
payload = json.dumps(payload)
|
216 |
print(payload)
|
217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
with gr.Blocks() as demo2:
|
219 |
gr.Markdown(
|
220 |
"""
|
@@ -356,6 +374,12 @@ with gr.Blocks() as demo2:
|
|
356 |
submit_button = gr.Button(
|
357 |
value="Submit",
|
358 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
submit_button.click(
|
360 |
submit,
|
361 |
inputs=[
|
@@ -369,12 +393,8 @@ with gr.Blocks() as demo2:
|
|
369 |
compute_selector,
|
370 |
min_node_selector,
|
371 |
max_node_selector,
|
372 |
-
security_selector]
|
373 |
-
|
374 |
-
status_txt = gr.Textbox(
|
375 |
-
value="any status update will be displayed here",
|
376 |
-
interactive=False
|
377 |
-
)
|
378 |
|
379 |
gr.TabbedInterface(
|
380 |
[demo2], ["Deploy on 🤗 Endpoint"]
|
|
|
183 |
type = compute_resources[-1].strip()
|
184 |
|
185 |
payload = {
|
186 |
+
"accountId": repository_selector.split("/")[0],
|
187 |
"compute": {
|
188 |
"accelerator": accelerator,
|
189 |
"instanceSize": size[1:],
|
|
|
202 |
"revision": head_sha,
|
203 |
"task": task_selector.lower()
|
204 |
},
|
205 |
+
"name": endpoint_name_input.strip(),
|
206 |
"provider": {
|
207 |
"region": region_selector.split("/")[0].lower(),
|
208 |
"vendor": provider_selector.lower()
|
|
|
215 |
payload = json.dumps(payload)
|
216 |
print(payload)
|
217 |
|
218 |
+
headers = {
|
219 |
+
"Authorization": f"Bearer {hf_token_input.strip()}",
|
220 |
+
"Content-Type": "application/json",
|
221 |
+
}
|
222 |
+
endpoint_url = f"https://api.endpoints.huggingface.cloud/endpoint"
|
223 |
+
print(endpoint_url)
|
224 |
+
|
225 |
+
response = requests.post(endpoint_url, headers=headers, json=payload)
|
226 |
+
|
227 |
+
if response.status_code == 400:
|
228 |
+
return f"Malformed data in {payload}"
|
229 |
+
elif response.status_code == 401:
|
230 |
+
return "Invalid token"
|
231 |
+
elif response.status_code == 409:
|
232 |
+
return f"Endpoint {endpoint_name_input} already exists"
|
233 |
+
else:
|
234 |
+
return f"Endpoint {endpoint_name_input} created successfully on {provider_selector.lower()} using {repository_selector.lower()}@{head_sha}"
|
235 |
+
|
236 |
with gr.Blocks() as demo2:
|
237 |
gr.Markdown(
|
238 |
"""
|
|
|
374 |
submit_button = gr.Button(
|
375 |
value="Submit",
|
376 |
)
|
377 |
+
|
378 |
+
status_txt = gr.Textbox(
|
379 |
+
value="any status update will be displayed here",
|
380 |
+
interactive=False
|
381 |
+
)
|
382 |
+
|
383 |
submit_button.click(
|
384 |
submit,
|
385 |
inputs=[
|
|
|
393 |
compute_selector,
|
394 |
min_node_selector,
|
395 |
max_node_selector,
|
396 |
+
security_selector],
|
397 |
+
outputs=status_txt)
|
|
|
|
|
|
|
|
|
398 |
|
399 |
gr.TabbedInterface(
|
400 |
[demo2], ["Deploy on 🤗 Endpoint"]
|