Commit
·
27e5eec
1
Parent(s):
9f8ddd4
RTS Human Evaluation
Browse files
app.py
CHANGED
|
@@ -15,6 +15,16 @@ from filelock import FileLock
|
|
| 15 |
# Configuration
|
| 16 |
# ----------------------
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
# Reviewer messaging
|
| 19 |
TARGET_PER_PERSON = 30
|
| 20 |
CONTACT_EMAIL = "ffallah[at]asu.edu"
|
|
@@ -62,6 +72,60 @@ class Sample:
|
|
| 62 |
gt_path: str
|
| 63 |
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
# === GLOBAL ROUND / ASSIGNMENT HELPERS ===
|
| 66 |
|
| 67 |
def _load_json(path: str) -> Dict[str, Any]:
|
|
|
|
| 15 |
# Configuration
|
| 16 |
# ----------------------
|
| 17 |
|
| 18 |
+
from huggingface_hub import HfApi, CommitOperationAdd # pip install huggingface_hub
|
| 19 |
+
|
| 20 |
+
HF_RESULTS_REPO = os.getenv("HF_RESULTS_REPO") # e.g. "yourname/rts-eval-results"
|
| 21 |
+
HF_RESULTS_REPO_TYPE = "dataset" # keep as dataset for private storage
|
| 22 |
+
HF_TOKEN = os.getenv("HF_TOKEN") # set as a Secret in the Space
|
| 23 |
+
|
| 24 |
+
_hf_api = HfApi(token=HF_TOKEN)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
| 28 |
# Reviewer messaging
|
| 29 |
TARGET_PER_PERSON = 30
|
| 30 |
CONTACT_EMAIL = "ffallah[at]asu.edu"
|
|
|
|
| 72 |
gt_path: str
|
| 73 |
|
| 74 |
|
| 75 |
+
|
| 76 |
+
def _ensure_private_repo(repo_id: str):
|
| 77 |
+
# Create if missing (as private)
|
| 78 |
+
try:
|
| 79 |
+
_hf_api.repo_info(repo_id, repo_type=HF_RESULTS_REPO_TYPE)
|
| 80 |
+
except Exception:
|
| 81 |
+
_hf_api.create_repo(
|
| 82 |
+
repo_id=repo_id,
|
| 83 |
+
repo_type=HF_RESULTS_REPO_TYPE,
|
| 84 |
+
private=True
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
def push_results_to_private_repo(uid: str):
|
| 88 |
+
"""
|
| 89 |
+
Upload the consolidated all_results.jsonl and the per-user file
|
| 90 |
+
to a PRIVATE dataset repo, so only you/collaborators can see it.
|
| 91 |
+
No-op if HF_RESULTS_REPO or HF_TOKEN isn't configured.
|
| 92 |
+
"""
|
| 93 |
+
if not HF_TOKEN or not HF_RESULTS_REPO:
|
| 94 |
+
# Not configured -> silently skip
|
| 95 |
+
return
|
| 96 |
+
|
| 97 |
+
try:
|
| 98 |
+
_ensure_private_repo(HF_RESULTS_REPO)
|
| 99 |
+
|
| 100 |
+
# Make sure files exist so we can upload them
|
| 101 |
+
os.makedirs(RESULTS_DIR, exist_ok=True)
|
| 102 |
+
open(ALL_RESULTS_JSONL, "a").close()
|
| 103 |
+
user_file = os.path.join(RESULTS_DIR, f"{uid}.jsonl")
|
| 104 |
+
open(user_file, "a").close()
|
| 105 |
+
|
| 106 |
+
ops = [
|
| 107 |
+
CommitOperationAdd(
|
| 108 |
+
path_in_repo="results/all_results.jsonl",
|
| 109 |
+
path_or_fileobj=ALL_RESULTS_JSONL
|
| 110 |
+
),
|
| 111 |
+
CommitOperationAdd(
|
| 112 |
+
path_in_repo=f"results/users/{uid}.jsonl",
|
| 113 |
+
path_or_fileobj=user_file
|
| 114 |
+
),
|
| 115 |
+
]
|
| 116 |
+
|
| 117 |
+
_hf_api.create_commit(
|
| 118 |
+
repo_id=HF_RESULTS_REPO,
|
| 119 |
+
repo_type=HF_RESULTS_REPO_TYPE,
|
| 120 |
+
operations=ops,
|
| 121 |
+
commit_message="Update RTS eval results"
|
| 122 |
+
)
|
| 123 |
+
except Exception as e:
|
| 124 |
+
# Don’t crash the UI if the Hub is temporarily unavailable.
|
| 125 |
+
print("[WARN] push_results_to_private_repo failed:", e)
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
|
| 129 |
# === GLOBAL ROUND / ASSIGNMENT HELPERS ===
|
| 130 |
|
| 131 |
def _load_json(path: str) -> Dict[str, Any]:
|