diff --git a/docs/api/restclient.md b/docs/api/restclient.md index 249c526..2d67a40 100644 --- a/docs/api/restclient.md +++ b/docs/api/restclient.md @@ -313,10 +313,13 @@ model card, and upload to the Hugging Face Hub. Args: - `tinker_path`: The tinker path to the checkpoint (e.g., "tinker://run-id/weights/0001") - `repo_id`: Hugging Face repo ID (e.g., "username/my-lora-adapter"). If None, - a name is derived from the base model and checkpoint path. + a name is derived from the base model and training run, and `revision` is + derived from the checkpoint id. - `private`: Whether to create the repo as private (default True) -- `token`: Hugging Face access token (optional) -- `revision`: Target branch/revision to upload to (optional) +- `token`: Hugging Face access token (optional). If None, uses the token + from `hf auth login` or the `HF_TOKEN` env var if available. +- `revision`: Target branch/revision to upload to (optional). If None and + repo_id is None, defaults to a name derived from the checkpoint id. - `commit_message`: Commit message for the upload (optional) - `create_pr`: Whether to create a PR instead of pushing to the main branch - `exist_ok`: Whether repo creation should succeed if repo exists diff --git a/src/tinker/lib/public_interfaces/rest_client.py b/src/tinker/lib/public_interfaces/rest_client.py index 7df81eb..e512132 100644 --- a/src/tinker/lib/public_interfaces/rest_client.py +++ b/src/tinker/lib/public_interfaces/rest_client.py @@ -425,8 +425,10 @@ class RestClient(TelemetryProvider): - `repo_id`: Hugging Face repo ID (e.g., "username/my-lora-adapter"). If None, a name is derived from the base model and checkpoint path. - `private`: Whether to create the repo as private (default False) - - `token`: Hugging Face access token (optional) - - `revision`: Target branch/revision to upload to (optional) + - `token`: Hugging Face access token (optional). If None, uses the token + from `hf auth login` or the `HF_TOKEN` env var if available. + - `revision`: Target branch/revision to upload to (optional). If None and + repo_id is None, defaults to a name derived from the checkpoint id. - `commit_message`: Commit message for the upload (optional) - `create_pr`: Whether to create a PR instead of pushing to the main branch - `exist_ok`: Whether repo creation should succeed if repo exists @@ -535,9 +537,10 @@ class RestClient(TelemetryProvider): if repo_id is None: base_short = base_model.split("/")[-1] if base_model != "unknown" else "adapter" - checkpoint_id = parsed_tinker_path.checkpoint_id.replace("/", "-") - derived = f"tinker-{base_short}-{parsed_tinker_path.training_run_id}-{checkpoint_id}" + derived = f"tinker-{base_short}-{parsed_tinker_path.training_run_id}" repo_id = _sanitize_repo_name(derived) + if revision is None: + revision = _sanitize_repo_name(parsed_tinker_path.checkpoint_id.replace("/", "-")) # Add a lightweight model card if missing readme_path = extract_dir / "README.md"