Spaces:
Running
Running
Update app.py
Browse filesfixing cold cache
app.py
CHANGED
@@ -7,7 +7,7 @@ from pathlib import Path
|
|
7 |
from typing import List, Dict, Any
|
8 |
|
9 |
import gradio as gr
|
10 |
-
from huggingface_hub import CommitScheduler
|
11 |
|
12 |
# ------------------------------
|
13 |
# Config
|
@@ -36,7 +36,24 @@ def _now_iso() -> str:
|
|
36 |
|
37 |
def read_all_records() -> List[Dict[str, Any]]:
|
38 |
records: List[Dict[str, Any]] = []
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
try:
|
41 |
with p.open("r", encoding="utf-8") as f:
|
42 |
for line in f:
|
|
|
7 |
from typing import List, Dict, Any
|
8 |
|
9 |
import gradio as gr
|
10 |
+
from huggingface_hub import CommitScheduler, snapshot_download
|
11 |
|
12 |
# ------------------------------
|
13 |
# Config
|
|
|
36 |
|
37 |
def read_all_records() -> List[Dict[str, Any]]:
|
38 |
records: List[Dict[str, Any]] = []
|
39 |
+
|
40 |
+
local_files = sorted(LOCAL_SUBMISSIONS_DIR.glob("*.jsonl"))
|
41 |
+
sources = list(local_files)
|
42 |
+
|
43 |
+
if not sources:
|
44 |
+
try:
|
45 |
+
snap_dir = Path(snapshot_download(
|
46 |
+
repo_id=DATASET_REPO_ID,
|
47 |
+
repo_type="dataset",
|
48 |
+
allow_patterns="data/*.jsonl"
|
49 |
+
))
|
50 |
+
hub_data_dir = snap_dir / "data"
|
51 |
+
sources = sorted(hub_data_dir.glob("*.jsonl"))
|
52 |
+
except Exception:
|
53 |
+
# If snapshot fails (e.g., offline), we just return empty
|
54 |
+
sources = []
|
55 |
+
|
56 |
+
for p in sources:
|
57 |
try:
|
58 |
with p.open("r", encoding="utf-8") as f:
|
59 |
for line in f:
|