The Repository
class is a helper class that wraps git
and git-lfs
commands. It provides tooling adapted
for managing repositories which can be very large.
It is the recommended tool as soon as any git
operation is involved, or when collaboration will be a point
of focus with the repository itself.
( local_dir: typing.Union[str, pathlib.Path] clone_from: typing.Optional[str] = None repo_type: typing.Optional[str] = None token: typing.Union[bool, str] = True git_user: typing.Optional[str] = None git_email: typing.Optional[str] = None revision: typing.Optional[str] = None skip_lfs_files: bool = False client: typing.Optional[huggingface_hub.hf_api.HfApi] = None )
Helper class to wrap the git and git-lfs commands.
The aim is to facilitate interacting with huggingface.co hosted model or dataset repos, though not a lot here (if any) is actually specific to huggingface.co.
Repository() is deprecated in favor of the http-based alternatives implemented in
HfApi. Given its large adoption in legacy code, the complete removal of
Repository() will only happen in release v1.0
. For more details, please read
https://huggingface.co/docs/huggingface_hub/concepts/git_vs_http.
( folder: typing.Union[str, pathlib.Path] ) → bool
Check if the folder is the root or part of a git repository
( folder: typing.Union[str, pathlib.Path] remote_url: str ) → bool
Check if the folder is a local clone of the remote_url
( filename: typing.Union[str, pathlib.Path] ) → bool
Check if the file passed is tracked with git-lfs.
( filename: typing.Union[str, pathlib.Path] ) → bool
Check if file is git-ignored. Supports nested .gitignore files.
( pattern: str = '.' folder: typing.Union[str, pathlib.Path, NoneType] = None ) → List[str]
Returns a list of filenames that are to be staged.
( folder: typing.Union[str, pathlib.Path] ) → bool
Check if the current checked-out branch is tracked upstream.
( folder: typing.Union[str, pathlib.Path] upstream: typing.Optional[str] = None ) → int
Check the number of commits that would be pushed upstream
The name of the upstream repository with which the comparison should be made.
The Repository
utility offers several methods which can be launched asynchronously:
git_push
git_pull
push_to_hub
commit
context managerSee below for utilities to manage such asynchronous methods.
( local_dir: typing.Union[str, pathlib.Path] clone_from: typing.Optional[str] = None repo_type: typing.Optional[str] = None token: typing.Union[bool, str] = True git_user: typing.Optional[str] = None git_email: typing.Optional[str] = None revision: typing.Optional[str] = None skip_lfs_files: bool = False client: typing.Optional[huggingface_hub.hf_api.HfApi] = None )
Helper class to wrap the git and git-lfs commands.
The aim is to facilitate interacting with huggingface.co hosted model or dataset repos, though not a lot here (if any) is actually specific to huggingface.co.
Repository() is deprecated in favor of the http-based alternatives implemented in
HfApi. Given its large adoption in legacy code, the complete removal of
Repository() will only happen in release v1.0
. For more details, please read
https://huggingface.co/docs/huggingface_hub/concepts/git_vs_http.
( title: str is_done_method: typing.Callable status_method: typing.Callable process: Popen post_method: typing.Optional[typing.Callable] = None )
Utility to follow commands launched asynchronously.