Skip to content

Description:

  • Work with data in github

Resources:

This notebook reads its settings from environment variables. Set them before starting Jupyter:

  • GITHUB_ORG: GitHub organization or user that owns the repository
  • GITHUB_REPO: repository name
  • GITHUB_USERNAME: your GitHub user name
  • GITHUB_TOKEN: a GitHub personal access token that can read the repository

Only Example 2 needs these; Example 1 reads a public repository anonymously.

Unauthorized Access. Listing objects in a repo.

from fsspec import filesystem
# Example: https://github.com/fsspec/filesystem_spec
fs = filesystem("github", org="fsspec", repo="filesystem_spec")
fs.ls("")

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