use both model and bucket volumes
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
from flask import Flask
|
| 3 |
|
| 4 |
app = Flask(__name__)
|
|
@@ -8,22 +9,33 @@ def index():
|
|
| 8 |
model_dir = "/model"
|
| 9 |
data_dir = "/data"
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
return f"""<html><body style="font-family: -apple-system, sans-serif; max-width: 600px; margin: 40px auto;">
|
| 24 |
-
<h1>
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
</body></html>"""
|
| 28 |
|
| 29 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import os
|
| 2 |
+
from datetime import datetime
|
| 3 |
from flask import Flask
|
| 4 |
|
| 5 |
app = Flask(__name__)
|
|
|
|
| 9 |
model_dir = "/model"
|
| 10 |
data_dir = "/data"
|
| 11 |
|
| 12 |
+
# Write visit to bucket
|
| 13 |
+
os.makedirs(data_dir, exist_ok=True)
|
| 14 |
+
visits_path = os.path.join(data_dir, "visits.txt")
|
| 15 |
+
with open(visits_path, "a") as f:
|
| 16 |
+
f.write(f"{datetime.utcnow().isoformat()}Z\n")
|
| 17 |
+
with open(visits_path) as f:
|
| 18 |
+
visits = f.read().strip().split("\n")
|
| 19 |
+
|
| 20 |
+
# List model files
|
| 21 |
+
model_files = []
|
| 22 |
+
if os.path.exists(model_dir):
|
| 23 |
+
for e in sorted(os.listdir(model_dir)):
|
| 24 |
+
p = os.path.join(model_dir, e)
|
| 25 |
+
if os.path.isfile(p):
|
| 26 |
+
model_files.append(f"<li>{e} ({os.path.getsize(p):,} bytes)</li>")
|
| 27 |
+
else:
|
| 28 |
+
model_files.append(f"<li>{e}/</li>")
|
| 29 |
|
| 30 |
return f"""<html><body style="font-family: -apple-system, sans-serif; max-width: 600px; margin: 40px auto;">
|
| 31 |
+
<h1>Two Volumes Test</h1>
|
| 32 |
+
|
| 33 |
+
<h2>/model <span style="color:#86868b; font-weight:400; font-size:14px;">(read-only, openai-community/gpt2)</span></h2>
|
| 34 |
+
<ul>{"".join(model_files) if model_files else "<li>empty</li>"}</ul>
|
| 35 |
+
|
| 36 |
+
<h2>/data <span style="color:#86868b; font-weight:400; font-size:14px;">(read-write, victor/caca bucket)</span></h2>
|
| 37 |
+
<p>{len(visits)} visit{"s" if len(visits) != 1 else ""} recorded. Data persists across restarts.</p>
|
| 38 |
+
<pre style="background:#f5f5f7; padding:12px; border-radius:8px; font-size:13px; max-height:200px; overflow:auto;">{chr(10).join(visits[-20:])}</pre>
|
| 39 |
</body></html>"""
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|