Description:
- Work with data in github
Resources:
- [Source Code] https://filesystem-spec.readthedocs.io/en/latest/_modules/fsspec/implementations/github.html?highlight=github#
- [Docs] https://filesystem-spec.readthedocs.io/en/latest/api.html?highlight=github#fsspec.implementations.github.GithubFileSystem
Environment variables
Section titled “Environment variables”This notebook reads its settings from environment variables. Set them before starting Jupyter:
GITHUB_ORG: GitHub organization or user that owns the repositoryGITHUB_REPO: repository nameGITHUB_USERNAME: your GitHub user nameGITHUB_TOKEN: a GitHub personal access token that can read the repository
Only Example 2 needs these; Example 1 reads a public repository anonymously.
Example 1
Section titled “Example 1”Unauthorized Access. Listing objects in a repo.
from fsspec import filesystem
# Example: https://github.com/fsspec/filesystem_specfs = filesystem("github", org="fsspec", repo="filesystem_spec")fs.ls("")Example 2
Section titled “Example 2”Authorized access. Listing objects in a repo.
For authorised access, you must provide username and token, which can be made at https://github.com/settings/tokens
import os
from fsspec import filesystem
# Example: https://github.com/<org>/<repo>fs = filesystem( "github", org=os.environ["GITHUB_ORG"], repo=os.environ["GITHUB_REPO"], username=os.environ["GITHUB_USERNAME"], token=os.environ["GITHUB_TOKEN"],)fs.ls("")ganymede is made by Eugo