Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -57,6 +57,15 @@ def get_hardware_requirements(space: Dict) -> str:
|
|
57 |
else:
|
58 |
return 'CPU' if space.get('host_requirements', {}).get('hardware', {}).get('gpu') is False else 'GPU'
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
def format_space(space: Dict) -> Dict:
|
61 |
space_id = space.get('id', 'Unknown')
|
62 |
space_name = space_id.split('/')[-1] if '/' in space_id else space_id
|
@@ -80,18 +89,6 @@ def format_space(space: Dict) -> Dict:
|
|
80 |
"thumbnail": thumbnail,
|
81 |
"hardware": hardware
|
82 |
}
|
83 |
-
|
84 |
-
def format_spaces(spaces: Union[List[Dict], str]) -> List[Dict]:
|
85 |
-
if isinstance(spaces, str):
|
86 |
-
return [{"error": spaces}]
|
87 |
-
|
88 |
-
# Ensure that all items in the list are dictionaries
|
89 |
-
valid_spaces = [space for space in spaces if isinstance(space, dict)]
|
90 |
-
|
91 |
-
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
|
92 |
-
return list(executor.map(format_space, valid_spaces))
|
93 |
-
|
94 |
-
|
95 |
|
96 |
def get_app_py_content(space_id: str) -> str:
|
97 |
app_py_url = f"https://huggingface.co/spaces/{space_id}/raw/main/app.py"
|
|
|
57 |
else:
|
58 |
return 'CPU' if space.get('host_requirements', {}).get('hardware', {}).get('gpu') is False else 'GPU'
|
59 |
|
60 |
+
def format_spaces(spaces: Union[List[Dict], str]) -> List[Dict]:
|
61 |
+
if isinstance(spaces, str):
|
62 |
+
return [{"error": spaces}]
|
63 |
+
|
64 |
+
valid_spaces = [space for space in spaces if isinstance(space, dict)]
|
65 |
+
|
66 |
+
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
|
67 |
+
return list(executor.map(format_space, valid_spaces))
|
68 |
+
|
69 |
def format_space(space: Dict) -> Dict:
|
70 |
space_id = space.get('id', 'Unknown')
|
71 |
space_name = space_id.split('/')[-1] if '/' in space_id else space_id
|
|
|
89 |
"thumbnail": thumbnail,
|
90 |
"hardware": hardware
|
91 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
def get_app_py_content(space_id: str) -> str:
|
94 |
app_py_url = f"https://huggingface.co/spaces/{space_id}/raw/main/app.py"
|