towhee.hub.repo_manager.RepoManager¶
- class towhee.hub.repo_manager.RepoManager(author: str, repo: str, root: str = 'https://towhee.io')[source]¶
Bases:
object
Base Repo Manager class to create, initialize, download repos.
- Parameters:
author (str) – The author of the repo.
repo (str) – The name of the repo.
root (str) – The root url of the repo.
Methods
Download repo without git.
Load the content from url and write into local files.
Download the given files.
Check if a repo exists.
Get all the files in the current repo at the given commit.
Get the repo type.
Grab the latest commit of a tag.
Download the .gitattributes file from the specified repo in order to figure out which files are being tracked by git-lfs.
Attributes
author
repo
root
- download(local_repo_path: Union[str, Path] = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/towhee/checkouts/branch0.8.0/towhee/doc/source'), tag: str = 'main', install_reqs: bool = True) None [source]¶
Download repo without git.
- Agrs:
- local_repo_path (Union[str, Path]):
Thre local dir to download the files into.
- tag (str):
The tag of the repo to download.
- install_reqs (bool):
Whether to install packages from requirements.txt.
- download_executor(tag: str, file_name: str, lfs_files: Tuple[str], local_repo_path: Union[str, Path]) None [source]¶
Load the content from url and write into local files.
- Parameters:
tag (str) – The tag name.
file_name (str) – The hub file paths.
lfs_files (`str) – The file extensions being tracked by git-lfs.
local_repo_path (Union[str, Path]) – The local directory to download to.
- Raises:
(HTTPError) – Rasie error in request.
(OSError) – Raise error in writing file.
- download_files(tag: str, file_list: List[str], lfs_files: List[str], local_repo_path: Union[str, Path], install_reqs: bool) None [source]¶
Download the given files.
- Agrs:
- tag (str):
The tag of the repo to download.
- file_list (List[str]):
The files to download
- lfs_files (List[str]):
The lfs files extensions.
- local_repo_path (Union[str, Path]):
Thre local dir to download the files into.
- install_reqs (bool):
Whether to install packages from requirements.txt.
- exists() bool [source]¶
Check if a repo exists.
- Returns:
- (bool)
return True if the repository exists, else False.
- get_file_list(commit: str) List[str] [source]¶
Get all the files in the current repo at the given commit.
This is done through forming a git tree recursively and filtering out all the files.
- Parameters:
commit (str) – The commit to base current existing files.
- Returns:
- (List[str])
The file paths for the repo
- Raises:
(HTTPError) – Raise error in request.
- latest_commit(tag: str) str [source]¶
Grab the latest commit of a tag.
- Parameters:
tag (str) – The tag name.
- Returns:
- (str)
The latest commit hash cut down to 10 characters.
- Raises:
(HTTPError) – Raise error in request.
- obtain_lfs_extensions(tag: str) List[str] [source]¶
Download the .gitattributes file from the specified repo in order to figure out which files are being tracked by git-lfs.
Lines that deal with git-lfs take on the following format:
- Parameters:
tag (str) – The tag name.
- Returns:
- (List[str])
The list of file extentions tracked by git-lfs.