Spaces:
Runtime error
Runtime error
Factor Studios
commited on
Upload 4 files
Browse files- app.py +3 -3
- http_storage.py +7 -22
- static/style.css +69 -0
- templates/dashboard.html +55 -0
app.py
CHANGED
|
@@ -15,9 +15,9 @@ from datetime import datetime
|
|
| 15 |
from fastapi.responses import FileResponse
|
| 16 |
import humanize
|
| 17 |
|
| 18 |
-
# Import
|
| 19 |
from test_ai_integration_http import test_ai_integration_http
|
| 20 |
-
from http_storage import
|
| 21 |
|
| 22 |
# Initialize FastAPI app
|
| 23 |
app = FastAPI()
|
|
@@ -191,7 +191,7 @@ with open(templates_dir / "dashboard.html", "w") as f:
|
|
| 191 |
f.write(html_content)
|
| 192 |
|
| 193 |
# Initialize storage
|
| 194 |
-
storage =
|
| 195 |
|
| 196 |
@app.get("/", response_class=HTMLResponse)
|
| 197 |
async def get_dashboard(request: Request):
|
|
|
|
| 15 |
from fastapi.responses import FileResponse
|
| 16 |
import humanize
|
| 17 |
|
| 18 |
+
# Import storage and test module
|
| 19 |
from test_ai_integration_http import test_ai_integration_http
|
| 20 |
+
from http_storage import LocalStorage
|
| 21 |
|
| 22 |
# Initialize FastAPI app
|
| 23 |
app = FastAPI()
|
|
|
|
| 191 |
f.write(html_content)
|
| 192 |
|
| 193 |
# Initialize storage
|
| 194 |
+
storage = LocalStorage()
|
| 195 |
|
| 196 |
@app.get("/", response_class=HTMLResponse)
|
| 197 |
async def get_dashboard(request: Request):
|
http_storage.py
CHANGED
|
@@ -48,29 +48,14 @@ class LocalStorage:
|
|
| 48 |
|
| 49 |
self.lock = threading.Lock()
|
| 50 |
self._closing = False
|
| 51 |
-
self.
|
| 52 |
-
self.last_error_time = 0
|
| 53 |
-
self.session_id = str(uuid.uuid4())
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
'loaded_models': set()
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
# Initialize local storage monitoring
|
| 65 |
-
self.storage_monitor = {
|
| 66 |
-
'total_size': 0,
|
| 67 |
-
'last_access': time.time(),
|
| 68 |
-
'disk_usage': os.path.getsize(str(self.base_path)) if os.path.exists(str(self.base_path)) else 0
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
# Initialize session
|
| 72 |
-
self._create_session()
|
| 73 |
-
self.initialized = True
|
| 74 |
|
| 75 |
def __init__(self, storage_path: str = "storage"):
|
| 76 |
"""This will actually just return the singleton instance.
|
|
|
|
| 48 |
|
| 49 |
self.lock = threading.Lock()
|
| 50 |
self._closing = False
|
| 51 |
+
self._connected = True # Local storage is always "connected"
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
def wait_for_connection(self, timeout: float = 30.0) -> bool:
|
| 54 |
+
"""
|
| 55 |
+
Simulates connection wait for compatibility with previous interfaces.
|
| 56 |
+
Always returns True for local storage since no connection is needed.
|
| 57 |
+
"""
|
| 58 |
+
return self.ping()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
def __init__(self, storage_path: str = "storage"):
|
| 61 |
"""This will actually just return the singleton instance.
|
static/style.css
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
body {
|
| 2 |
+
font-family: 'Arial', sans-serif;
|
| 3 |
+
margin: 0;
|
| 4 |
+
padding: 20px;
|
| 5 |
+
background: #f5f5f5;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
.container {
|
| 9 |
+
max-width: 1200px;
|
| 10 |
+
margin: 0 auto;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
.stats-grid {
|
| 14 |
+
display: grid;
|
| 15 |
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
| 16 |
+
gap: 20px;
|
| 17 |
+
margin-bottom: 30px;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.stat-card {
|
| 21 |
+
background: white;
|
| 22 |
+
padding: 20px;
|
| 23 |
+
border-radius: 10px;
|
| 24 |
+
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
.stat-title {
|
| 28 |
+
font-size: 14px;
|
| 29 |
+
color: #666;
|
| 30 |
+
margin-bottom: 10px;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
.stat-value {
|
| 34 |
+
font-size: 24px;
|
| 35 |
+
color: #2c3e50;
|
| 36 |
+
font-weight: bold;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.files-section {
|
| 40 |
+
background: white;
|
| 41 |
+
padding: 20px;
|
| 42 |
+
border-radius: 10px;
|
| 43 |
+
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
table {
|
| 47 |
+
width: 100%;
|
| 48 |
+
border-collapse: collapse;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
th, td {
|
| 52 |
+
padding: 12px;
|
| 53 |
+
text-align: left;
|
| 54 |
+
border-bottom: 1px solid #eee;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
th {
|
| 58 |
+
background: #f8f9fa;
|
| 59 |
+
color: #666;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
.header {
|
| 63 |
+
margin-bottom: 30px;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.header h1 {
|
| 67 |
+
color: #2c3e50;
|
| 68 |
+
margin: 0;
|
| 69 |
+
}
|
templates/dashboard.html
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<title>Storage Dashboard</title>
|
| 5 |
+
<link rel="stylesheet" href="{{ url_for('static', path='style.css') }}">
|
| 6 |
+
</head>
|
| 7 |
+
<body>
|
| 8 |
+
<div class="container">
|
| 9 |
+
<div class="header">
|
| 10 |
+
<h1>Storage Dashboard</h1>
|
| 11 |
+
</div>
|
| 12 |
+
|
| 13 |
+
<div class="stats-grid">
|
| 14 |
+
<div class="stat-card">
|
| 15 |
+
<div class="stat-title">VRAM Used</div>
|
| 16 |
+
<div class="stat-value">{{ vram_used }}</div>
|
| 17 |
+
</div>
|
| 18 |
+
<div class="stat-card">
|
| 19 |
+
<div class="stat-title">Active Tensors</div>
|
| 20 |
+
<div class="stat-value">{{ active_tensors }}</div>
|
| 21 |
+
</div>
|
| 22 |
+
<div class="stat-card">
|
| 23 |
+
<div class="stat-title">Loaded Models</div>
|
| 24 |
+
<div class="stat-value">{{ loaded_models }}</div>
|
| 25 |
+
</div>
|
| 26 |
+
<div class="stat-card">
|
| 27 |
+
<div class="stat-title">Storage Size</div>
|
| 28 |
+
<div class="stat-value">{{ storage_size }}</div>
|
| 29 |
+
</div>
|
| 30 |
+
</div>
|
| 31 |
+
|
| 32 |
+
<div class="files-section">
|
| 33 |
+
<h2>Storage Contents</h2>
|
| 34 |
+
<table>
|
| 35 |
+
<thead>
|
| 36 |
+
<tr>
|
| 37 |
+
<th>File</th>
|
| 38 |
+
<th>Size</th>
|
| 39 |
+
<th>Last Modified</th>
|
| 40 |
+
</tr>
|
| 41 |
+
</thead>
|
| 42 |
+
<tbody>
|
| 43 |
+
{% for file in files %}
|
| 44 |
+
<tr>
|
| 45 |
+
<td>{{ file.name }}</td>
|
| 46 |
+
<td>{{ file.size }}</td>
|
| 47 |
+
<td>{{ file.modified }}</td>
|
| 48 |
+
</tr>
|
| 49 |
+
{% endfor %}
|
| 50 |
+
</tbody>
|
| 51 |
+
</table>
|
| 52 |
+
</div>
|
| 53 |
+
</div>
|
| 54 |
+
</body>
|
| 55 |
+
</html>
|