Spaces:
Sleeping
Sleeping
debug
Browse files- app/main.py +7 -0
- app/static/js/main.js +12 -2
- docker-compose.yml +5 -1
app/main.py
CHANGED
|
@@ -41,10 +41,17 @@ async def home(request: Request):
|
|
| 41 |
async def get_model_list():
|
| 42 |
logger.info("Fetching model list")
|
| 43 |
try:
|
|
|
|
|
|
|
|
|
|
| 44 |
# Get actual model configurations
|
| 45 |
model_list = utils.get_hub_cached_models(mode="inference")
|
| 46 |
logger.info(f"Found {len(model_list)} models")
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
# Transform the data into the expected format
|
| 49 |
models = []
|
| 50 |
seen_models = set()
|
|
|
|
| 41 |
async def get_model_list():
|
| 42 |
logger.info("Fetching model list")
|
| 43 |
try:
|
| 44 |
+
# Ensure cache directory exists
|
| 45 |
+
os.makedirs("/cache", exist_ok=True)
|
| 46 |
+
|
| 47 |
# Get actual model configurations
|
| 48 |
model_list = utils.get_hub_cached_models(mode="inference")
|
| 49 |
logger.info(f"Found {len(model_list)} models")
|
| 50 |
|
| 51 |
+
if not model_list:
|
| 52 |
+
logger.warning("No models found")
|
| 53 |
+
return JSONResponse(content=[])
|
| 54 |
+
|
| 55 |
# Transform the data into the expected format
|
| 56 |
models = []
|
| 57 |
seen_models = set()
|
app/static/js/main.js
CHANGED
|
@@ -24,13 +24,23 @@ async function fetchModels() {
|
|
| 24 |
|
| 25 |
try {
|
| 26 |
const response = await fetch('/api/models');
|
|
|
|
|
|
|
|
|
|
| 27 |
const data = await response.json();
|
| 28 |
-
models
|
|
|
|
| 29 |
renderModels();
|
| 30 |
updatePagination();
|
| 31 |
} catch (error) {
|
| 32 |
console.error('Error fetching models:', error);
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
} finally {
|
| 35 |
loadingModels.style.display = 'none';
|
| 36 |
}
|
|
|
|
| 24 |
|
| 25 |
try {
|
| 26 |
const response = await fetch('/api/models');
|
| 27 |
+
if (!response.ok) {
|
| 28 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
| 29 |
+
}
|
| 30 |
const data = await response.json();
|
| 31 |
+
console.log('Fetched models:', data);
|
| 32 |
+
models = data || [];
|
| 33 |
renderModels();
|
| 34 |
updatePagination();
|
| 35 |
} catch (error) {
|
| 36 |
console.error('Error fetching models:', error);
|
| 37 |
+
modelGrid.innerHTML = `
|
| 38 |
+
<div class="empty-state">
|
| 39 |
+
<i class="fas fa-exclamation-circle"></i>
|
| 40 |
+
<h4>Error loading models</h4>
|
| 41 |
+
<p>${error.message}</p>
|
| 42 |
+
</div>
|
| 43 |
+
`;
|
| 44 |
} finally {
|
| 45 |
loadingModels.style.display = 'none';
|
| 46 |
}
|
docker-compose.yml
CHANGED
|
@@ -7,4 +7,8 @@ services:
|
|
| 7 |
environment:
|
| 8 |
- HF_TOKEN=${HF_TOKEN}
|
| 9 |
volumes:
|
| 10 |
-
- ./app:/app/app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
environment:
|
| 8 |
- HF_TOKEN=${HF_TOKEN}
|
| 9 |
volumes:
|
| 10 |
+
- ./app:/app/app
|
| 11 |
+
- cache_data:/cache
|
| 12 |
+
|
| 13 |
+
volumes:
|
| 14 |
+
cache_data:
|