Skip to content

Commit

Permalink
annotations: use GITHUT_PAT env variable for Github queries if avail.
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed May 16, 2024
1 parent 7801679 commit 6b881aa
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions fafbseg/flywire/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,26 +1542,36 @@ def _get_cached_annotation_materializations(commit):
return np.array(mats)


@lru_cache
def _get_github_session():
s = requests.Session()
if "GITHUB_PAT" in os.environ:
s.auth = ('user', 'pass')
s.headers.update({'Authorization': f"Bearer {os.environ['GITHUB_PAT']}"})

return s


@lru_cache
def _get_available_annotation_versions():
# Get available tags
r = requests.get("https://api.github.com/repos/flyconnectome/flywire_annotations/tags")
r = _get_github_session().get("https://api.github.com/repos/flyconnectome/flywire_annotations/tags")
r.raise_for_status()
return r.json()


@lru_cache
def _get_available_commits():
# Get available commits
r = requests.get("https://api.github.com/repos/flyconnectome/flywire_annotations/commits")
r = _get_github_session().get("https://api.github.com/repos/flyconnectome/flywire_annotations/commits")
r.raise_for_status()
return r.json()


@lru_cache
def _get_available_branches():
# Get available tags
r = requests.get("https://api.github.com/repos/flyconnectome/flywire_annotations/branches")
r = _get_github_session().get("https://api.github.com/repos/flyconnectome/flywire_annotations/branches")
r.raise_for_status()
return r.json()

Expand Down

0 comments on commit 6b881aa

Please sign in to comment.