Spaces:
Build error
Build error
Commit
·
3e317b0
1
Parent(s):
b219560
- write a function for splitting the input
Browse files
app.py
CHANGED
|
@@ -15,6 +15,21 @@ class SpaceBuilder:
|
|
| 15 |
error_message = None
|
| 16 |
url = None
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
@classmethod
|
| 19 |
def file_as_a_string(cls, name_list: List[str]) -> str:
|
| 20 |
"""
|
|
@@ -40,7 +55,7 @@ class SpaceBuilder:
|
|
| 40 |
:param hf_token: HuggingFace Write Token
|
| 41 |
:return: True if success
|
| 42 |
"""
|
| 43 |
-
name_list =
|
| 44 |
create_repo(name=space_name, token=hf_token, repo_type="space", space_sdk="gradio")
|
| 45 |
repo = get_full_repo_name(model_id=space_name, token=hf_token)
|
| 46 |
|
|
@@ -76,7 +91,7 @@ class SpaceBuilder:
|
|
| 76 |
:param names: Input space names
|
| 77 |
:return: True check is successful
|
| 78 |
"""
|
| 79 |
-
name_list =
|
| 80 |
try:
|
| 81 |
interfaces = [gr.Interface.load(name) for name in name_list]
|
| 82 |
except Exception as ex:
|
|
|
|
| 15 |
error_message = None
|
| 16 |
url = None
|
| 17 |
|
| 18 |
+
@classmethod
|
| 19 |
+
def split_space_names(cls, names: str) -> List[str]:
|
| 20 |
+
"""
|
| 21 |
+
Splits and filters the given space_names.
|
| 22 |
+
|
| 23 |
+
:param names: names
|
| 24 |
+
:return: Name List
|
| 25 |
+
"""
|
| 26 |
+
name_list = names.split("\n")
|
| 27 |
+
filtered_list = []
|
| 28 |
+
for name in name_list:
|
| 29 |
+
if not (name == "" or name.isspace()):
|
| 30 |
+
filtered_list.append(name)
|
| 31 |
+
return filtered_list
|
| 32 |
+
|
| 33 |
@classmethod
|
| 34 |
def file_as_a_string(cls, name_list: List[str]) -> str:
|
| 35 |
"""
|
|
|
|
| 55 |
:param hf_token: HuggingFace Write Token
|
| 56 |
:return: True if success
|
| 57 |
"""
|
| 58 |
+
name_list = cls.split_space_names(names)
|
| 59 |
create_repo(name=space_name, token=hf_token, repo_type="space", space_sdk="gradio")
|
| 60 |
repo = get_full_repo_name(model_id=space_name, token=hf_token)
|
| 61 |
|
|
|
|
| 91 |
:param names: Input space names
|
| 92 |
:return: True check is successful
|
| 93 |
"""
|
| 94 |
+
name_list = cls.split_space_names(names)
|
| 95 |
try:
|
| 96 |
interfaces = [gr.Interface.load(name) for name in name_list]
|
| 97 |
except Exception as ex:
|