Spaces:
Build error
Build error
Commit
·
8ca56b3
1
Parent(s):
8f8e04c
small refactors
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from typing import List
|
|
3 |
import numpy as np
|
4 |
import requests
|
5 |
import gradio as gr
|
|
|
6 |
|
7 |
from huggingface_hub import (
|
8 |
create_repo,
|
@@ -36,11 +37,13 @@ class SpaceBuilder:
|
|
36 |
Returns the file that is going to be created in the new space as string.
|
37 |
|
38 |
:param name_list: list of space names
|
|
|
|
|
39 |
:return: file as a string
|
40 |
"""
|
41 |
return (
|
42 |
f"import gradio as gr"
|
43 |
-
f"\nname_list = {name_list}
|
44 |
f"\ninterfaces = [gr.Interface.load(name) for name in name_list]"
|
45 |
f"\ngr.mix.Parallel(*interfaces, title=\"{title}\", description=\"{description}\").launch()"
|
46 |
)
|
@@ -62,7 +65,7 @@ class SpaceBuilder:
|
|
62 |
create_repo(name=space_name, token=hf_token, repo_type="space", space_sdk="gradio")
|
63 |
except Exception as ex:
|
64 |
print(ex)
|
65 |
-
cls.error_message = "Please
|
66 |
return False
|
67 |
repo_name = get_full_repo_name(model_id=space_name, token=hf_token)
|
68 |
|
@@ -76,6 +79,8 @@ class SpaceBuilder:
|
|
76 |
cls.error_message = "An exception occurred during temporary file writing"
|
77 |
return False
|
78 |
|
|
|
|
|
79 |
try:
|
80 |
file_url = upload_file(
|
81 |
path_or_fileobj="temp_file.txt",
|
|
|
3 |
import numpy as np
|
4 |
import requests
|
5 |
import gradio as gr
|
6 |
+
import time
|
7 |
|
8 |
from huggingface_hub import (
|
9 |
create_repo,
|
|
|
37 |
Returns the file that is going to be created in the new space as string.
|
38 |
|
39 |
:param name_list: list of space names
|
40 |
+
:param title: title
|
41 |
+
:param description: description
|
42 |
:return: file as a string
|
43 |
"""
|
44 |
return (
|
45 |
f"import gradio as gr"
|
46 |
+
f"\nname_list = {name_list}"
|
47 |
f"\ninterfaces = [gr.Interface.load(name) for name in name_list]"
|
48 |
f"\ngr.mix.Parallel(*interfaces, title=\"{title}\", description=\"{description}\").launch()"
|
49 |
)
|
|
|
65 |
create_repo(name=space_name, token=hf_token, repo_type="space", space_sdk="gradio")
|
66 |
except Exception as ex:
|
67 |
print(ex)
|
68 |
+
cls.error_message = "Please provide a correct space name as Only regular characters and '-', '_', '.' accepted. '--' and '..' are forbidden. '-' and '.' cannot start or end the name."
|
69 |
return False
|
70 |
repo_name = get_full_repo_name(model_id=space_name, token=hf_token)
|
71 |
|
|
|
79 |
cls.error_message = "An exception occurred during temporary file writing"
|
80 |
return False
|
81 |
|
82 |
+
# Sleep a litle bit otherwise the interface might not build at the space after uploading a file
|
83 |
+
time.sleep(1)
|
84 |
try:
|
85 |
file_url = upload_file(
|
86 |
path_or_fileobj="temp_file.txt",
|