Spaces:
Sleeping
Sleeping
Update leaderboard via Leaderboarder
Browse files- app.py +18 -12
- leaderboarder/deploy.py +20 -12
- leaderboarder/storage.py +9 -1
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -55,12 +55,15 @@ def run_build_and_deploy(
|
|
| 55 |
run_id = datetime.now(timezone.utc).strftime("%Y%m%d-%H%M%S")
|
| 56 |
base_slug = slugify(benchmark_input)
|
| 57 |
output_dir = WORKDIR / f"{base_slug}-{run_id}"
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
owner = resolve_owner(settings.hf_token)
|
| 66 |
if not owner:
|
|
@@ -72,12 +75,15 @@ def run_build_and_deploy(
|
|
| 72 |
target_space = f"{owner}/leaderboarder-{slugify(summary.benchmark_name)}"
|
| 73 |
|
| 74 |
generate_space_artifacts(Path(summary.output_dir), summary.benchmark_name)
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
csv_path = Path(summary.output_dir) / "leaderboard.csv"
|
| 83 |
preview = pd.read_csv(csv_path).head(25) if csv_path.exists() else pd.DataFrame()
|
|
|
|
| 55 |
run_id = datetime.now(timezone.utc).strftime("%Y%m%d-%H%M%S")
|
| 56 |
base_slug = slugify(benchmark_input)
|
| 57 |
output_dir = WORKDIR / f"{base_slug}-{run_id}"
|
| 58 |
+
try:
|
| 59 |
+
summary = pipeline.run(
|
| 60 |
+
input_value=benchmark_input,
|
| 61 |
+
output_dir=str(output_dir),
|
| 62 |
+
max_citations=int(max_citations),
|
| 63 |
+
read_citations=int(read_citations),
|
| 64 |
+
)
|
| 65 |
+
except Exception as exc:
|
| 66 |
+
return f"Build failed: {exc}", "", pd.DataFrame()
|
| 67 |
|
| 68 |
owner = resolve_owner(settings.hf_token)
|
| 69 |
if not owner:
|
|
|
|
| 75 |
target_space = f"{owner}/leaderboarder-{slugify(summary.benchmark_name)}"
|
| 76 |
|
| 77 |
generate_space_artifacts(Path(summary.output_dir), summary.benchmark_name)
|
| 78 |
+
try:
|
| 79 |
+
deployed_url = deploy_to_hf_space(
|
| 80 |
+
output_dir=Path(summary.output_dir),
|
| 81 |
+
space_id=target_space,
|
| 82 |
+
hf_token=settings.hf_token,
|
| 83 |
+
private=bool(private_space),
|
| 84 |
+
)
|
| 85 |
+
except Exception as exc:
|
| 86 |
+
return f"Deployment failed: {exc}", json.dumps(summary.to_dict(), indent=2, ensure_ascii=False), pd.DataFrame()
|
| 87 |
|
| 88 |
csv_path = Path(summary.output_dir) / "leaderboard.csv"
|
| 89 |
preview = pd.read_csv(csv_path).head(25) if csv_path.exists() else pd.DataFrame()
|
leaderboarder/deploy.py
CHANGED
|
@@ -78,6 +78,7 @@ demo.launch()
|
|
| 78 |
|
| 79 |
SPACE_REQUIREMENTS = """gradio>=4.44.0
|
| 80 |
pandas>=2.2.2
|
|
|
|
| 81 |
"""
|
| 82 |
|
| 83 |
BUILDER_SPACE_REQUIREMENTS = """gradio>=4.44.0
|
|
@@ -89,6 +90,7 @@ pyarrow>=16.1.0
|
|
| 89 |
pypdf>=4.3.1
|
| 90 |
python-dotenv>=1.0.1
|
| 91 |
requests>=2.32.3
|
|
|
|
| 92 |
trafilatura>=1.12.2
|
| 93 |
"""
|
| 94 |
|
|
@@ -149,12 +151,15 @@ def run_build_and_deploy(
|
|
| 149 |
run_id = datetime.now(timezone.utc).strftime("%Y%m%d-%H%M%S")
|
| 150 |
base_slug = slugify(benchmark_input)
|
| 151 |
output_dir = WORKDIR / f"{base_slug}-{run_id}"
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
owner = resolve_owner(settings.hf_token)
|
| 160 |
if not owner:
|
|
@@ -166,12 +171,15 @@ def run_build_and_deploy(
|
|
| 166 |
target_space = f"{owner}/leaderboarder-{slugify(summary.benchmark_name)}"
|
| 167 |
|
| 168 |
generate_space_artifacts(Path(summary.output_dir), summary.benchmark_name)
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
csv_path = Path(summary.output_dir) / "leaderboard.csv"
|
| 177 |
preview = pd.read_csv(csv_path).head(25) if csv_path.exists() else pd.DataFrame()
|
|
|
|
| 78 |
|
| 79 |
SPACE_REQUIREMENTS = """gradio>=4.44.0
|
| 80 |
pandas>=2.2.2
|
| 81 |
+
tabulate>=0.9.0
|
| 82 |
"""
|
| 83 |
|
| 84 |
BUILDER_SPACE_REQUIREMENTS = """gradio>=4.44.0
|
|
|
|
| 90 |
pypdf>=4.3.1
|
| 91 |
python-dotenv>=1.0.1
|
| 92 |
requests>=2.32.3
|
| 93 |
+
tabulate>=0.9.0
|
| 94 |
trafilatura>=1.12.2
|
| 95 |
"""
|
| 96 |
|
|
|
|
| 151 |
run_id = datetime.now(timezone.utc).strftime("%Y%m%d-%H%M%S")
|
| 152 |
base_slug = slugify(benchmark_input)
|
| 153 |
output_dir = WORKDIR / f"{base_slug}-{run_id}"
|
| 154 |
+
try:
|
| 155 |
+
summary = pipeline.run(
|
| 156 |
+
input_value=benchmark_input,
|
| 157 |
+
output_dir=str(output_dir),
|
| 158 |
+
max_citations=int(max_citations),
|
| 159 |
+
read_citations=int(read_citations),
|
| 160 |
+
)
|
| 161 |
+
except Exception as exc:
|
| 162 |
+
return f"Build failed: {exc}", "", pd.DataFrame()
|
| 163 |
|
| 164 |
owner = resolve_owner(settings.hf_token)
|
| 165 |
if not owner:
|
|
|
|
| 171 |
target_space = f"{owner}/leaderboarder-{slugify(summary.benchmark_name)}"
|
| 172 |
|
| 173 |
generate_space_artifacts(Path(summary.output_dir), summary.benchmark_name)
|
| 174 |
+
try:
|
| 175 |
+
deployed_url = deploy_to_hf_space(
|
| 176 |
+
output_dir=Path(summary.output_dir),
|
| 177 |
+
space_id=target_space,
|
| 178 |
+
hf_token=settings.hf_token,
|
| 179 |
+
private=bool(private_space),
|
| 180 |
+
)
|
| 181 |
+
except Exception as exc:
|
| 182 |
+
return f"Deployment failed: {exc}", json.dumps(summary.to_dict(), indent=2, ensure_ascii=False), pd.DataFrame()
|
| 183 |
|
| 184 |
csv_path = Path(summary.output_dir) / "leaderboard.csv"
|
| 185 |
preview = pd.read_csv(csv_path).head(25) if csv_path.exists() else pd.DataFrame()
|
leaderboarder/storage.py
CHANGED
|
@@ -97,7 +97,7 @@ def save_leaderboard(
|
|
| 97 |
public_frame.to_csv(csv_path, index=False)
|
| 98 |
public_frame.to_json(json_path, orient="records", indent=2, force_ascii=False)
|
| 99 |
public_frame.to_parquet(parquet_path, index=False)
|
| 100 |
-
md_path.write_text(
|
| 101 |
frame.to_json(raw_json_path, orient="records", indent=2, force_ascii=False)
|
| 102 |
|
| 103 |
return {
|
|
@@ -220,3 +220,11 @@ def _unique_preserve_order(values: list[str]) -> list[str]:
|
|
| 220 |
seen.add(item)
|
| 221 |
out.append(item)
|
| 222 |
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
public_frame.to_csv(csv_path, index=False)
|
| 98 |
public_frame.to_json(json_path, orient="records", indent=2, force_ascii=False)
|
| 99 |
public_frame.to_parquet(parquet_path, index=False)
|
| 100 |
+
md_path.write_text(_to_markdown_safe(public_frame), encoding="utf-8")
|
| 101 |
frame.to_json(raw_json_path, orient="records", indent=2, force_ascii=False)
|
| 102 |
|
| 103 |
return {
|
|
|
|
| 220 |
seen.add(item)
|
| 221 |
out.append(item)
|
| 222 |
return out
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
def _to_markdown_safe(frame: pd.DataFrame) -> str:
|
| 226 |
+
try:
|
| 227 |
+
return frame.to_markdown(index=False)
|
| 228 |
+
except Exception:
|
| 229 |
+
# Fallback when optional dependency `tabulate` is unavailable.
|
| 230 |
+
return frame.to_csv(index=False)
|
requirements.txt
CHANGED
|
@@ -7,4 +7,5 @@ pyarrow>=16.1.0
|
|
| 7 |
pypdf>=4.3.1
|
| 8 |
python-dotenv>=1.0.1
|
| 9 |
requests>=2.32.3
|
|
|
|
| 10 |
trafilatura>=1.12.2
|
|
|
|
| 7 |
pypdf>=4.3.1
|
| 8 |
python-dotenv>=1.0.1
|
| 9 |
requests>=2.32.3
|
| 10 |
+
tabulate>=0.9.0
|
| 11 |
trafilatura>=1.12.2
|