class_docstr: Mixin providing support for uploading adapters to HuggingFace's Model Hub.
docstr: Upload an adapter to HuggingFace's Model Hub.
  
  Args:
      repo_name (str): The name of the repository on the model hub to upload to.
      adapter_name (str): The name of the adapter to be uploaded.
      organization (str, optional): Organization in which to push the adapter
          (you must be a member of this organization). Defaults to None.
      adapterhub_tag (str, optional):
          Tag of the format `<task>/<subtask>` for categorization on https://adapterhub.ml/explore/. See
          https://docs.adapterhub.ml/contributing.html#add-a-new-task-or-subtask for more. If not specified,
          `datasets_tag` must be given in case a new adapter card is generated. Defaults to None.
      datasets_tag (str, optional): Dataset identifier from https://huggingface.co/datasets.
          If not specified, `adapterhub_tag` must be given in case a new adapter card is generated. Defaults to
          None.
      local_path (str, optional): Local path used as clone directory of the adapter repository.
          If not specified, will create a temporary directory. Defaults to None.
      commit_message (:obj:`str`, `optional`):
          Message to commit while pushing. Will default to :obj:`"add config"`, :obj:`"add tokenizer"` or
          :obj:`"add model"` depending on the type of the class.
      private (:obj:`bool`, `optional`):
          Whether or not the repository created should be private (requires a paying subscription).
      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`
          is not specified.
      overwrite_adapter_card (bool, optional): Overwrite an existing adapter card with a newly generated one.
          If set to `False`, will only generate an adapter card, if none exists. Defaults to False.
      create_pr (bool, optional):
          Whether or not to create a PR with the uploaded files or directly commit.
      revision (`str`, *optional*):
          Branch to push the uploaded files to.
      commit_description (`str`, *optional*):
          The description of the commit that will be created
  
  Returns:
      str: The url of the adapter repository on the model hub.
docstr_tok: ["Upload","an","adapter","to","HuggingFace","'s","Model","Hub",".","Args",":","repo_name","(","str",")",":","The","name","of","the","repository","on","the","model","hub","to","upload","to",".","adapter_name","(","str",")",":","The","name","of","the","adapter","to","be","uploaded",".","organization","(","str",",","optional",")",":","Organization","in","which","to","push","the","adapter","(","you","must","be","a","member","of","this","organization",")",".","Defaults","to","None",".","adapterhub_tag","(","str",",","optional",")",":","Tag","of","the","format","`","<","task",">","\/","<","subtask",">","`","for","categorization","on","https",":","\/\/adapterhub.ml\/explore\/",".","See","https",":","\/\/docs.adapterhub.ml\/contributing.html","#","add-a-new-task-or-subtask","for","more",".","If","not","specified",",","`","datasets_tag","`","must","be","given","in","case","a","new","adapter","card","is","generated",".","Defaults","to","None",".","datasets_tag","(","str",",","optional",")",":","Dataset","identifier","from","https",":","\/\/huggingface.co\/datasets",".","If","not","specified",",","`","adapterhub_tag","`","must","be","given","in","case","a","new","adapter","card","is","generated",".","Defaults","to","None",".","local_path","(","str",",","optional",")",":","Local","path","used","as","clone","directory","of","the","adapter","repository",".","If","not","specified",",","will","create","a","temporary","directory",".","Defaults","to","None",".","commit_message","(",":","obj",":","`","str","`",",","`","optional","`",")",":","Message","to","commit","while","pushing",".","Will","default","to",":","obj",":","`","``","add","config","''","`",",",":","obj",":","`","``","add","tokenizer","''","`","or",":","obj",":","`","``","add","model","''","`","depending","on","the","type","of","the","class",".","private","(",":","obj",":","`","bool","`",",","`","optional","`",")",":","Whether","or","not","the","repository","created","should","be","private","(","requires","a","paying","subscription",")",".","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","`","is","not","specified",".","overwrite_adapter_card","(","bool",",","optional",")",":","Overwrite","an","existing","adapter","card","with","a","newly","generated","one",".","If","set","to","`","False","`",",","will","only","generate","an","adapter","card",",","if","none","exists",".","Defaults","to","False",".","create_pr","(","bool",",","optional",")",":","Whether","or","not","to","create","a","PR","with","the","uploaded","files","or","directly","commit",".","revision","(","`","str","`",",","*","optional","*",")",":","Branch","to","push","the","uploaded","files","to",".","commit_description","(","`","str","`",",","*","optional","*",")",":","The","description","of","the","commit","that","will","be","created","Returns",":","str",":","The","url","of","the","adapter","repository","on","the","model","hub","."]
code: def push_adapter_to_hub(
      self,
      repo_name: str,
      adapter_name: str,
      organization: Optional[str] = None,
      adapterhub_tag: Optional[str] = None,
      datasets_tag: Optional[str] = None,
      local_path: Optional[str] = None,
      commit_message: Optional[str] = None,
      private: Optional[bool] = None,
      token: Optional[Union[bool, str]] = None,
      overwrite_adapter_card: bool = False,
      create_pr: bool = False,
      revision: str = None,
      commit_description: str = None,
      adapter_card_kwargs: Optional[dict] = None,
      **deprecated_kwargs,
  ):
      """Upload an adapter to HuggingFace's Model Hub.
  
      Args:
          repo_name (str): The name of the repository on the model hub to upload to.
          adapter_name (str): The name of the adapter to be uploaded.
          organization (str, optional): Organization in which to push the adapter
              (you must be a member of this organization). Defaults to None.
          adapterhub_tag (str, optional):
              Tag of the format `<task>/<subtask>` for categorization on https://adapterhub.ml/explore/. See
              https://docs.adapterhub.ml/contributing.html#add-a-new-task-or-subtask for more. If not specified,
              `datasets_tag` must be given in case a new adapter card is generated. Defaults to None.
          datasets_tag (str, optional): Dataset identifier from https://huggingface.co/datasets.
              If not specified, `adapterhub_tag` must be given in case a new adapter card is generated. Defaults to
              None.
          local_path (str, optional): Local path used as clone directory of the adapter repository.
              If not specified, will create a temporary directory. Defaults to None.
          commit_message (:obj:`str`, `optional`):
              Message to commit while pushing. Will default to :obj:`"add config"`, :obj:`"add tokenizer"` or
              :obj:`"add model"` depending on the type of the class.
          private (:obj:`bool`, `optional`):
              Whether or not the repository created should be private (requires a paying subscription).
          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`
              is not specified.
          overwrite_adapter_card (bool, optional): Overwrite an existing adapter card with a newly generated one.
              If set to `False`, will only generate an adapter card, if none exists. Defaults to False.
          create_pr (bool, optional):
              Whether or not to create a PR with the uploaded files or directly commit.
          revision (`str`, *optional*):
              Branch to push the uploaded files to.
          commit_description (`str`, *optional*):
              The description of the commit that will be created
  
      Returns:
          str: The url of the adapter repository on the model hub.
      """
      use_auth_token = deprecated_kwargs.pop("use_auth_token", None)
      if use_auth_token is not None:
          warnings.warn(
              "The `use_auth_token` argument is deprecated and will be removed in future versions of Adapters."
              " Please use `token` instead.",
              FutureWarning,
          )
          if token is not None:
              raise ValueError(
                  "`token` and `use_auth_token` are both specified. Please set only the argument `token`."
              )
          token = use_auth_token
  
      if organization is not None and not repo_name.startswith(
          organization
      ):
          warnings.warn(
              "The `organization` argument is deprecated and will be removed in future versions of"
              " Adapters. Set your organization directly in the `repo_id` passed instead"
              " (`repo_id={organization}/{model_id}`)."
          )
          if "/" in repo_name:
              repo_name = repo_name.split("/")[-1]
          repo_id = f"{organization}/{repo_name}"
      else:
          repo_id = repo_name
  
      use_temp_dir = (
          not os.path.isdir(local_path) if local_path else True
      )
  
      # Create repo or get retrieve an existing repo
      repo_id = self._create_repo(repo_id, private=private, token=token)
  
      # Commit and push
      logger.info(
          'Pushing adapter "%s" to model hub at %s ...',
          adapter_name,
          repo_id,
      )
      with working_or_temp_dir(
          working_dir=local_path, use_temp_dir=use_temp_dir
      ) as work_dir:
          files_timestamps = self._get_files_timestamps(work_dir)
          # Save adapter and optionally create model card
          self.save_adapter(work_dir, adapter_name)
          if overwrite_adapter_card or not os.path.exists(
              os.path.join(work_dir, "README.md")
          ):
              adapter_card_kwargs = adapter_card_kwargs or {}
              self._save_adapter_card(
                  work_dir,
                  adapter_name,
                  repo_id,
                  adapterhub_tag=adapterhub_tag,
                  datasets_tag=datasets_tag,
                  **adapter_card_kwargs,
              )
          return self._upload_modified_files(
              work_dir,
              repo_id,
              files_timestamps,
              commit_message=commit_message,
              token=token,
              create_pr=create_pr,
              revision=revision,
              commit_description=commit_description,
          )
  
file_path: adapters/src/adapters/hub_mixin.py
imports: import logging
  import os
  import warnings
  from typing import List, Optional, Union
  from transformers.utils.generic import working_or_temp_dir
label_desc: Use image node_id 2 for calling the PushAdapterToHubMixin obj's underlying member method code with example usage: obj.push_adapter_to_hub(repo_name, adapter_name, organization, adapterhub_tag, datasets_tag, local_path, commit_message, private, token, overwrite_adapter_card, create_pr, revision, commit_description, adapter_card_kwargs) and returns: self