From 0b5b5e6a70249837293499e9363a64765a57111c Mon Sep 17 00:00:00 2001 From: Lucain Date: Thu, 28 Nov 2024 17:05:08 +0100 Subject: [PATCH] Let server decide default repo visibility (#34999) * Let server decide default repo visibility * code style --- src/transformers/agents/tools.py | 2 +- src/transformers/modeling_tf_utils.py | 2 +- src/transformers/training_args.py | 15 ++++++++++----- src/transformers/utils/hub.py | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/transformers/agents/tools.py b/src/transformers/agents/tools.py index 6d3401bf30e9..e33e5cf5ce3c 100644 --- a/src/transformers/agents/tools.py +++ b/src/transformers/agents/tools.py @@ -387,7 +387,7 @@ def push_to_hub( commit_message (`str`, *optional*, defaults to `"Upload tool"`): Message to commit while pushing. private (`bool`, *optional*): - Whether or not the repository created should be private. + Whether to make the repo private. If `None` (default), the repo will be public unless the organization's default is private. This value is ignored if the repo already exists. token (`bool` or `str`, *optional*): The token to use as HTTP bearer authorization for remote files. If unset, will use the token generated when running `huggingface-cli login` (stored in `~/.huggingface`). diff --git a/src/transformers/modeling_tf_utils.py b/src/transformers/modeling_tf_utils.py index 7d62fe97007e..8264f48818cb 100644 --- a/src/transformers/modeling_tf_utils.py +++ b/src/transformers/modeling_tf_utils.py @@ -3160,7 +3160,7 @@ def push_to_hub( commit_message (`str`, *optional*): Message to commit while pushing. Will default to `"Upload model"`. private (`bool`, *optional*): - Whether or not the repository created should be private. + Whether to make the repo private. If `None` (default), the repo will be public unless the organization's default is private. This value is ignored if the repo already exists. token (`bool` or `str`, *optional*): The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated when running `huggingface-cli login` (stored in `~/.huggingface`). Will default to `True` if `repo_url` diff --git a/src/transformers/training_args.py b/src/transformers/training_args.py index 0653c8a2cb7b..6b141cff39e1 100644 --- a/src/transformers/training_args.py +++ b/src/transformers/training_args.py @@ -700,8 +700,8 @@ class TrainingArguments: hub_token (`str`, *optional*): The token to use to push the model to the Hub. Will default to the token in the cache folder obtained with `huggingface-cli login`. - hub_private_repo (`bool`, *optional*, defaults to `False`): - If True, the Hub repo will be set to private. + hub_private_repo (`bool`, *optional*): + Whether to make the repo private. If `None` (default), the repo will be public unless the organization's default is private. This value is ignored if the repo already exists. hub_always_push (`bool`, *optional*, defaults to `False`): Unless this is `True`, the `Trainer` will skip pushing a checkpoint when the previous push is not finished. gradient_checkpointing (`bool`, *optional*, defaults to `False`): @@ -1350,7 +1350,12 @@ class TrainingArguments: metadata={"help": "The hub strategy to use when `--push_to_hub` is activated."}, ) hub_token: Optional[str] = field(default=None, metadata={"help": "The token to use to push to the Model Hub."}) - hub_private_repo: bool = field(default=False, metadata={"help": "Whether the model repository is private or not."}) + hub_private_repo: Optional[bool] = field( + default=None, + metadata={ + "help": "Whether to make the repo private. If `None` (default), the repo will be public unless the organization's default is private. This value is ignored if the repo already exists." + }, + ) hub_always_push: bool = field( default=False, metadata={"help": "Unless `True`, the Trainer will skip pushes if the previous one wasn't finished yet."}, @@ -2862,7 +2867,7 @@ def set_push_to_hub( model_id: str, strategy: Union[str, HubStrategy] = "every_save", token: Optional[str] = None, - private_repo: bool = False, + private_repo: Optional[bool] = None, always_push: bool = False, ): """ @@ -2903,7 +2908,7 @@ def set_push_to_hub( The token to use to push the model to the Hub. Will default to the token in the cache folder obtained with `huggingface-cli login`. private_repo (`bool`, *optional*, defaults to `False`): - If True, the Hub repo will be set to private. + Whether to make the repo private. If `None` (default), the repo will be public unless the organization's default is private. This value is ignored if the repo already exists. always_push (`bool`, *optional*, defaults to `False`): Unless this is `True`, the `Trainer` will skip pushing a checkpoint when the previous push is not finished. diff --git a/src/transformers/utils/hub.py b/src/transformers/utils/hub.py index 54f763de335c..b7194ec579da 100644 --- a/src/transformers/utils/hub.py +++ b/src/transformers/utils/hub.py @@ -853,7 +853,7 @@ def push_to_hub( commit_message (`str`, *optional*): Message to commit while pushing. Will default to `"Upload {object}"`. private (`bool`, *optional*): - Whether or not the repository created should be private. + Whether to make the repo private. If `None` (default), the repo will be public unless the organization's default is private. This value is ignored if the repo already exists. token (`bool` or `str`, *optional*): The token to use as HTTP bearer authorization for remote files. If `True`, will use the token generated when running `huggingface-cli login` (stored in `~/.huggingface`). Will default to `True` if `repo_url`