|
|
import pandas as pd |
|
|
from huggingface_hub import HfApi, login |
|
|
import os |
|
|
|
|
|
|
|
|
HF_USERNAME = "gberseth" |
|
|
HF_TOKEN = os.environ.get("HF_TOKEN") |
|
|
|
|
|
|
|
|
REQUESTS_REPO = f"{HF_USERNAME}/rl-leaderboard-requests" |
|
|
RESULTS_REPO = f"{HF_USERNAME}/rl-leaderboard-results" |
|
|
|
|
|
|
|
|
|
|
|
api = HfApi() |
|
|
|
|
|
def create_dataset(repo_id, csv_filename, columns): |
|
|
print(f"Processing {repo_id}...") |
|
|
|
|
|
|
|
|
try: |
|
|
api.create_repo(repo_id=repo_id, repo_type="dataset", exist_ok=True) |
|
|
print(f"β
Repo '{repo_id}' created (or already exists).") |
|
|
except Exception as e: |
|
|
print(f"β Error creating repo: {e}") |
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
df = pd.DataFrame(columns=columns) |
|
|
df.to_csv(csv_filename, index=False) |
|
|
|
|
|
|
|
|
try: |
|
|
api.upload_file( |
|
|
path_or_fileobj=csv_filename, |
|
|
path_in_repo=csv_filename, |
|
|
repo_id=repo_id, |
|
|
repo_type="dataset" |
|
|
) |
|
|
print(f"β
Initial '{csv_filename}' uploaded to {repo_id}.") |
|
|
except Exception as e: |
|
|
print(f"β Error uploading file: {e}") |
|
|
|
|
|
|
|
|
if os.path.exists(csv_filename): |
|
|
os.remove(csv_filename) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
create_dataset( |
|
|
repo_id=REQUESTS_REPO, |
|
|
csv_filename="requests.csv", |
|
|
columns=["model_id", "status", "created_at", "submitted_by"] |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
create_dataset( |
|
|
repo_id=RESULTS_REPO, |
|
|
csv_filename="results.csv", |
|
|
columns=["model_id", "mean_reward", "run_time", "status", "completed_at"] |
|
|
) |
|
|
|
|
|
print("\nπ Setup complete! You can now link these datasets in your app.py files.") |