Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -157,6 +157,59 @@ def update_compute_options(provider, region):
|
|
157 |
value=avalialbe_compute_options[0] if len(avalialbe_compute_options) > 0 else None
|
158 |
)
|
159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
with gr.Blocks() as demo2:
|
161 |
gr.Markdown(
|
162 |
"""
|
@@ -299,20 +352,21 @@ with gr.Blocks() as demo2:
|
|
299 |
submit_button = gr.Button(
|
300 |
value="Submit",
|
301 |
)
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
|
|
316 |
|
317 |
status_txt = gr.Textbox(
|
318 |
value="any status update will be displayed here",
|
|
|
157 |
value=avalialbe_compute_options[0] if len(avalialbe_compute_options) > 0 else None
|
158 |
)
|
159 |
|
160 |
+
def submit(
|
161 |
+
hf_token_input,
|
162 |
+
endpoint_name_input,
|
163 |
+
provider_selector,
|
164 |
+
region_selector,
|
165 |
+
repository_selector,
|
166 |
+
revision_selector,
|
167 |
+
task_selector,
|
168 |
+
framework_selector,
|
169 |
+
compute_selector,
|
170 |
+
min_node_selector,
|
171 |
+
max_node_selector,
|
172 |
+
security_selector
|
173 |
+
):
|
174 |
+
compute_resources = compute_selector.split("·")
|
175 |
+
accelerator = compute_resources[0][:3].strip()
|
176 |
+
|
177 |
+
size_l_index = compute_resources[0].index("[")
|
178 |
+
size_r_index = compute_resources[0].index("]")
|
179 |
+
size = compute_resources[0][size_l_index : size_r_index+1].strip()
|
180 |
+
|
181 |
+
type = compute_resources[-1].strip()
|
182 |
+
|
183 |
+
payload = {
|
184 |
+
"accountId": "...",
|
185 |
+
"compute": {
|
186 |
+
"accelerator": accelerator,
|
187 |
+
"instanceSize": size,
|
188 |
+
"instanceType": type,
|
189 |
+
"scaling": {
|
190 |
+
"maxReplica": max_node_selector,
|
191 |
+
"minReplica": min_node_selector
|
192 |
+
}
|
193 |
+
},
|
194 |
+
"model": {
|
195 |
+
"framework": framework_selector.lower(),
|
196 |
+
"image": {
|
197 |
+
"huggingface": {}
|
198 |
+
},
|
199 |
+
"repository": repository_selector.lower(),
|
200 |
+
"revision": revision_selector.split("/")[1].lower(),
|
201 |
+
"task": task_selector.lower()
|
202 |
+
},
|
203 |
+
"name": endpoint_name_input,
|
204 |
+
"provider": {
|
205 |
+
"region": region_selector.split("/")[0].lower(),
|
206 |
+
"vendor": provider_selector.lower()
|
207 |
+
},
|
208 |
+
"type": security_selector.lower()
|
209 |
+
}
|
210 |
+
|
211 |
+
print(payload)
|
212 |
+
|
213 |
with gr.Blocks() as demo2:
|
214 |
gr.Markdown(
|
215 |
"""
|
|
|
352 |
submit_button = gr.Button(
|
353 |
value="Submit",
|
354 |
)
|
355 |
+
submit_button.click(
|
356 |
+
submit,
|
357 |
+
inputs=[
|
358 |
+
hf_token_input,
|
359 |
+
endpoint_name_input,
|
360 |
+
provider_selector,
|
361 |
+
region_selector,
|
362 |
+
repository_selector,
|
363 |
+
revision_selector,
|
364 |
+
task_selector,
|
365 |
+
framework_selector,
|
366 |
+
compute_selector,
|
367 |
+
min_node_selector,
|
368 |
+
max_node_selector,
|
369 |
+
security_selector])
|
370 |
|
371 |
status_txt = gr.Textbox(
|
372 |
value="any status update will be displayed here",
|