Skip to content

Commit

Permalink
CI/WEB: Adding cache for maintainers' github info (pandas-dev#50485)
Browse files Browse the repository at this point in the history
  • Loading branch information
datapythonista authored Dec 29, 2022
1 parent 797f23e commit 2899f46
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/docbuild-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ jobs:
- name: Build Pandas
uses: ./.github/actions/build_pandas

- name: Set up maintainers cache
uses: actions/cache@v3
with:
path: maintainers.json
key: maintainers

- name: Build website
run: python web/pandas_web.py web/pandas --target-path=web/build

Expand Down
17 changes: 17 additions & 0 deletions web/pandas_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import collections
import datetime
import importlib
import json
import operator
import os
import pathlib
Expand Down Expand Up @@ -163,6 +164,18 @@ def maintainers_add_info(context):
Given the active maintainers defined in the yaml file, it fetches
the GitHub user information for them.
"""
timestamp = time.time()

cache_file = pathlib.Path("maintainers.json")
if cache_file.is_file():
with open(cache_file) as f:
context["maintainers"] = json.load(f)
# refresh cache after 1 hour
if (timestamp - context["maintainers"]["timestamp"]) < 3_600:
return context

context["maintainers"]["timestamp"] = timestamp

repeated = set(context["maintainers"]["active"]) & set(
context["maintainers"]["inactive"]
)
Expand All @@ -179,6 +192,10 @@ def maintainers_add_info(context):
return context
resp.raise_for_status()
context["maintainers"][f"{kind}_with_github_info"].append(resp.json())

with open(cache_file, "w") as f:
json.dump(context["maintainers"], f)

return context

@staticmethod
Expand Down

0 comments on commit 2899f46

Please sign in to comment.