diff --git a/.github/workflows/docbuild-and-upload.yml b/.github/workflows/docbuild-and-upload.yml index 908259597cafb..7a9f491228a83 100644 --- a/.github/workflows/docbuild-and-upload.yml +++ b/.github/workflows/docbuild-and-upload.yml @@ -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 diff --git a/web/pandas_web.py b/web/pandas_web.py index e9e8e70066b3f..4c30e1959fdff 100755 --- a/web/pandas_web.py +++ b/web/pandas_web.py @@ -27,6 +27,7 @@ import collections import datetime import importlib +import json import operator import os import pathlib @@ -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"] ) @@ -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