Spaces:
Sleeping
Sleeping
Commit ·
89de692
1
Parent(s): ec86a50
fina p3
Browse files- src/app.py +19 -9
src/app.py
CHANGED
|
@@ -96,15 +96,25 @@ assets_path = os.path.join(STATIC_DIR, "assets")
|
|
| 96 |
if os.path.exists(assets_path):
|
| 97 |
app.mount("/assets", StaticFiles(directory=assets_path), name="assets")
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
-
|
| 106 |
-
for d in["data", "data/videos", "data/labels", "data/prompts", "data/responses", "metadata", "data/profiles", "data/comments", "data/mnl_labeled", "models/sandbox_autogluon"]:
|
| 107 |
-
os.makedirs(d, exist_ok=True)
|
| 108 |
|
| 109 |
try:
|
| 110 |
csv.field_size_limit(sys.maxsize)
|
|
@@ -230,7 +240,7 @@ async def get_benchmark_leaderboard():
|
|
| 230 |
|
| 231 |
@app.get("/config/prompts")
|
| 232 |
async def list_prompts():
|
| 233 |
-
return
|
| 234 |
|
| 235 |
@app.get("/config/tags")
|
| 236 |
async def list_configured_tags():
|
|
@@ -686,7 +696,7 @@ async def get_account_integrity():
|
|
| 686 |
existing_links_per_user[d.name].add(link)
|
| 687 |
|
| 688 |
scores_map = {}
|
| 689 |
-
for fname in
|
| 690 |
path = Path(fname)
|
| 691 |
if not path.exists(): continue
|
| 692 |
for row in common_utils.robust_read_csv(path):
|
|
|
|
| 96 |
if os.path.exists(assets_path):
|
| 97 |
app.mount("/assets", StaticFiles(directory=assets_path), name="assets")
|
| 98 |
|
| 99 |
+
# Safely Ensure all data directories exist
|
| 100 |
+
data_dirs =[
|
| 101 |
+
"data", "data/videos", "data/labels", "data/prompts",
|
| 102 |
+
"data/responses", "metadata", "data/profiles",
|
| 103 |
+
"data/comments", "data/mnl_labeled", "data/models/sandbox_autogluon"
|
| 104 |
+
]
|
| 105 |
|
| 106 |
+
for d in data_dirs:
|
| 107 |
+
try:
|
| 108 |
+
os.makedirs(d, exist_ok=True)
|
| 109 |
+
except PermissionError as e:
|
| 110 |
+
logger.warning(f"Permission denied creating directory {d}. Skipping. Error: {e}")
|
| 111 |
+
except Exception as e:
|
| 112 |
+
logger.warning(f"Failed to create directory {d}: {e}")
|
| 113 |
+
|
| 114 |
+
if os.path.isdir("data/videos"):
|
| 115 |
+
app.mount("/videos", StaticFiles(directory="data/videos"), name="videos")
|
| 116 |
|
| 117 |
+
templates = Jinja2Templates(directory=STATIC_DIR)
|
|
|
|
|
|
|
| 118 |
|
| 119 |
try:
|
| 120 |
csv.field_size_limit(sys.maxsize)
|
|
|
|
| 240 |
|
| 241 |
@app.get("/config/prompts")
|
| 242 |
async def list_prompts():
|
| 243 |
+
return[{"id": k, "name": v['description']} for k, v in PROMPT_VARIANTS.items()]
|
| 244 |
|
| 245 |
@app.get("/config/tags")
|
| 246 |
async def list_configured_tags():
|
|
|
|
| 696 |
existing_links_per_user[d.name].add(link)
|
| 697 |
|
| 698 |
scores_map = {}
|
| 699 |
+
for fname in["data/dataset.csv", "data/manual_dataset.csv"]:
|
| 700 |
path = Path(fname)
|
| 701 |
if not path.exists(): continue
|
| 702 |
for row in common_utils.robust_read_csv(path):
|