Improve error logging when creating a HF revision

This commit is contained in:
cmpatino 2026-02-03 11:11:17 +01:00
parent c8fb4f5ee1
commit f49ac445ca

View file

@ -498,15 +498,15 @@ def _export_checkpoint_to_hub(
# Create the revision/branch if specified and it doesn't exist
if revision:
try:
# Check if the branch exists
refs = api.list_repo_refs(repo_id=repo_id)
branch_exists = any(ref.name == revision for ref in refs.branches)
if not branch_exists:
# Create the branch from main
api.create_branch(repo_id=repo_id, branch=revision, exist_ok=True)
except Exception:
# If we can't check or create the branch, try to proceed anyway
pass
except Exception as e:
raise TinkerCliError(
f"Failed to create branch {revision} in repo {repo_id}",
f"Error: {e}",
) from e
def _readme_tinker_path() -> str | None:
try: