MCPcopy
hub / github.com/huggingface/transformers / push_to_hub

Method push_to_hub

src/transformers/trainer.py:4022–4102  ·  view source on GitHub ↗

Upload `self.model` and `self.processing_class` to the 🤗 model hub on the repo `self.args.hub_model_id`. Parameters: commit_message (`str`, *optional*, defaults to `"End of training"`): Message to commit while pushing. blocking (`bool`, *opti

(
        self,
        commit_message: str | None = "End of training",
        blocking: bool = True,
        token: str | None = None,
        revision: str | None = None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

4020 self.accelerator.unwrap_model(self.model).create_or_update_model_card(self.args.output_dir)
4021
4022 def push_to_hub(
4023 self,
4024 commit_message: str | None = "End of training",
4025 blocking: bool = True,
4026 token: str | None = None,
4027 revision: str | None = None,
4028 **kwargs,
4029 ) -> CommitInfo:
4030 """
4031 Upload `self.model` and `self.processing_class` to the 🤗 model hub on the repo `self.args.hub_model_id`.
4032
4033 Parameters:
4034 commit_message (`str`, *optional*, defaults to `"End of training"`):
4035 Message to commit while pushing.
4036 blocking (`bool`, *optional*, defaults to `True`):
4037 Whether the function should return only when the `git push` has finished.
4038 token (`str`, *optional*, defaults to `None`):
4039 Token with write permission to overwrite Trainer's original args.
4040 revision (`str`, *optional*):
4041 The git revision to commit from. Defaults to the head of the "main" branch.
4042 kwargs (`dict[str, Any]`, *optional*):
4043 Additional keyword arguments passed along to [`~Trainer.create_model_card`].
4044
4045 Returns:
4046 The URL of the repository where the model was pushed if `blocking=False`, or a `Future` object tracking the
4047 progress of the commit if `blocking=True`.
4048 """
4049 self.callback_handler.on_push_begin(self.args, self.state, self.control)
4050
4051 model_name = kwargs.pop("model_name", None)
4052 if model_name is None and self.args.should_save:
4053 if self.args.hub_model_id is None:
4054 model_name = Path(self.args.output_dir).name
4055 else:
4056 model_name = self.args.hub_model_id.split("/")[-1]
4057 token = token if token is not None else self.args.hub_token
4058
4059 # In case the user calls this method with args.push_to_hub = False
4060 if self.hub_model_id is None:
4061 self.init_hf_repo(token=token)
4062
4063 # Needs to be executed on all processes for TPU training, but will only save on the processed determined by
4064 # self.args.should_save.
4065 self.save_model(_internal_call=True)
4066
4067 # Only push from one node.
4068 if not self.is_world_process_zero():
4069 return
4070
4071 # Add additional tags in the case the model has already some tags and users pass
4072 # "tags" argument to `push_to_hub` so that trainer automatically handles internal tags
4073 # from all models since Trainer does not call `model.push_to_hub`.
4074 if getattr(self.model, "model_tags", None) is not None:
4075 if "tags" not in kwargs:
4076 kwargs["tags"] = []
4077
4078 # If it is a string, convert it to a list
4079 if isinstance(kwargs["tags"], str):

Callers 15

save_modelMethod · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95

Calls 9

init_hf_repoMethod · 0.95
save_modelMethod · 0.95
is_world_process_zeroMethod · 0.95
create_model_cardMethod · 0.95
_finish_current_pushMethod · 0.95
hf_apiFunction · 0.85
splitMethod · 0.80
on_push_beginMethod · 0.45
popMethod · 0.45