{"record":{"id":"1e0596e071be4b11","repo":"huggingface/open-r1","slug":"revision-training-args-hub-model-revision-alread","errorCode":null,"errorMessage":"Revision {training_args.hub_model_revision} already exists. Use --overwrite_hub_revision to overwrite it.","messagePattern":"Revision (.+?) already exists\\. Use --overwrite_hub_revision to overwrite it\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/open_r1/utils/hub.py","lineNumber":83,"sourceCode":"    logger.info(f\"Pushed to {repo_url} revision {training_args.hub_model_revision} successfully!\")\n\n    return future\n\n\ndef check_hub_revision_exists(training_args: SFTConfig | GRPOConfig):\n    \"\"\"Checks if a given Hub revision exists.\"\"\"\n    if repo_exists(training_args.hub_model_id):\n        if training_args.push_to_hub_revision is True:\n            # First check if the revision exists\n            revisions = [rev.name for rev in list_repo_refs(training_args.hub_model_id).branches]\n            # If the revision exists, we next check it has a README file\n            if training_args.hub_model_revision in revisions:\n                repo_files = list_repo_files(\n                    repo_id=training_args.hub_model_id,\n                    revision=training_args.hub_model_revision,\n                )\n                if \"README.md\" in repo_files and training_args.overwrite_hub_revision is False:\n                    raise ValueError(\n                        f\"Revision {training_args.hub_model_revision} already exists. \"\n                        \"Use --overwrite_hub_revision to overwrite it.\"\n                    )\n\n\ndef get_param_count_from_repo_id(repo_id: str) -> int:\n    \"\"\"Function to get model param counts from safetensors metadata or find patterns like 42m, 1.5b, 0.5m or products like 8x7b in a repo ID.\"\"\"\n    try:\n        metadata = get_safetensors_metadata(repo_id)\n        return list(metadata.parameter_count.values())[0]\n    except Exception:\n        # Pattern to match products (like 8x7b) and single values (like 42m)\n        pattern = r\"((\\d+(\\.\\d+)?)(x(\\d+(\\.\\d+)?))?)([bm])\"\n        matches = re.findall(pattern, repo_id.lower())\n\n        param_counts = []\n        for full_match, number1, _, _, number2, _, unit in matches:\n            if number2:  # If there's a second number, it's a product","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/huggingface/open-r1/blob/1416fa0cf21595d2083b399a2a0bbddd7f6e9563/src/open_r1/utils/hub.py#L65-L101","documentation":"check_hub_revision_exists raises ValueError when the target hub_model_revision already exists on the Hub, contains a README.md, and training_args.overwrite_hub_revision is False. This safety check prevents silently clobbering an existing published revision (an existing training run artifact). Users must explicitly opt in to overwrite.","triggerScenarios":"Re-running a training script with the same --hub_model_revision that was previously pushed, while the revision on the Hub already has a README.md and --overwrite_hub_revision was not passed.","commonSituations":"Resuming or re-running an experiment with unchanged args, CI re-running a job after a partial failure, shared team hub_model_id where another member already pushed that revision.","solutions":["Add --overwrite_hub_revision to intentionally replace the existing revision","Choose a new --hub_model_revision name (e.g. append a date/version suffix)","Delete or rename the existing revision on the Hub if it is no longer needed","Check existence beforehand with HfApi().list_repo_refs / list_repo_files to pick a free revision"],"exampleFix":"// before\npython train.py --hub_model_id org/model --hub_model_revision v1  # ValueError\n// after\npython train.py --hub_model_id org/model --hub_model_revision v1 --overwrite_hub_revision","handlingStrategy":"try-catch","validationCode":"from huggingface_hub import HfApi\n\ndef revision_exists_on_hub(hub_model_id, revision):\n    try:\n        refs = {r.name for r in HfApi().list_repo_refs(repo_id=hub_model_id).branches}\n        return revision in refs\n    except Exception:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    check_hub_revision_exists(training_args)\nexcept ValueError as e:\n    if \"already exists\" in str(e):\n        training_args.overwrite_hub_revision = True  # or pick a new revision\n        check_hub_revision_exists(training_args)\n    else:\n        raise","preventionTips":["Use unique revision names per run (timestamp or run-id suffix)","Set overwrite_hub_revision=True deliberately in CI rerun policies","Check existing refs with HfApi().list_repo_refs before launching long jobs","Coordinate shared hub_model_id usage within the team to avoid revision collisions"],"tags":["huggingface-hub","revision-conflict","configuration"],"backgroundTag":"hub-revision-already-exists","analyzedSha":"1416fa0cf21595d2083b399a2a0bbddd7f6e9563","analyzedAt":"2026-08-30T08:56:53.400Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}