fiftyone.utils.github¶
GitHub utilities.
Classes:
|
Class for interacting with a GitHub repository. |
-
class
fiftyone.utils.github.
GitHubRepository
(repo)¶ Bases:
object
Class for interacting with a GitHub repository.
Note
To interact with private GitHub repositories that you have access to, provide your GitHub personal access token by setting the
GITHUB_TOKEN
environment variable.- Parameters
repo –
the GitHub repository or identifier, which can be:
a GitHub repo URL like
https://github.com/<user>/<repo>
a GitHub ref like
https://github.com/<user>/<repo>/tree/<branch>
orhttps://github.com/<user>/<repo>/commit/<commit>
a GitHub ref string like
<user>/<repo>[/<ref>]
Attributes:
The username of the repo.
The name of the repo.
The ref (e.g.
The repository identifier string.
Methods:
Returns a dict of info about the repository.
get_file
(path[, outpath])Downloads the file at the given path.
list_path_contents
([path])Returns the contents of the repo rooted at the given path.
list_repo_contents
([recursive])Returns a flat list of the repository’s contents.
download
(outdir)Downloads the repository to the specified root directory.
parse_url
(url)parse_identifier
(identifier)-
property
user
¶ The username of the repo.
-
property
repo
¶ The name of the repo.
-
property
ref
¶ The ref (e.g. branch, tag, commit hash), if any.
-
property
identifier
¶ The repository identifier string.
-
get_repo_info
()¶ Returns a dict of info about the repository.
- Returns
an info dict
-
get_file
(path, outpath=None)¶ Downloads the file at the given path.
- Parameters
path – the filepath in the repository
outpath (None) – a path on disk to write the file
- Returns
the file bytes, if no
outpath
is provided
-
list_path_contents
(path=None)¶ Returns the contents of the repo rooted at the given path.
Note
This method has a limit of 1,000 files. Documentation.
- Parameters
path (None) – an optional root path to start the search from
- Returns
a list of file info dicts
-
list_repo_contents
(recursive=True)¶ Returns a flat list of the repository’s contents.
Note
This method has a limit of 100,000 entries and 7MB response size. Documentation.
- Parameters
recursive (True) – whether to recursively traverse subdirectories
- Returns
a list of file info dicts
-
download
(outdir)¶ Downloads the repository to the specified root directory.
- Parameters
outdir – the output directory
-
static
parse_url
(url)¶
-
static
parse_identifier
(identifier)¶