""" Helper script to reject a submission. Usage: python scripts/reject_submission.py \ --repo lms-shape-preferences/results-preference-base \ --token hf_... \ --path json/worker123/submission456.json This moves the file from json/ to rejected/ so the item gets re-assigned to the next available participant. """ import argparse import os import tempfile from huggingface_hub import HfApi def reject_submission(repo_id: str, file_path: str, token: str) -> None: assert file_path.startswith("json/"), \ f"Expected path starting with json/, got: {file_path}" api = HfApi(token=token) rejected_path = file_path.replace("json/", "rejected/", 1) print(f"Downloading {file_path} ...") local = api.hf_hub_download( repo_id=repo_id, filename=file_path, repo_type="dataset", token=token, ) print(f"Re-uploading to {rejected_path} ...") api.upload_file( path_or_fileobj=local, path_in_repo=rejected_path, repo_id=repo_id, repo_type="dataset", ) print(f"Deleting {file_path} ...") api.delete_file( path_in_repo=file_path, repo_id=repo_id, repo_type="dataset", ) print(f"Done. {file_path} → {rejected_path}") print("The item will be re-assigned within 5 minutes (cache TTL).") if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--repo", required=True) parser.add_argument("--token", default=os.getenv("HF_TOKEN")) parser.add_argument("--path", required=True, help="e.g. json/worker123/submission456.json") args = parser.parse_args() reject_submission(args.repo, args.path, args.token)