Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add json output #58

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ jobs:
cp -r conda-forge.github.io/sphinx/css site/.
cp -r conda-forge.github.io/sphinx/js site/.
cp -r conda-forge.github.io/sphinx/img site/.

- name: update JSON payload
shell: bash -l {0}
run: |
python scripts/all_json.py outputs/ site/feedstock-outputs.json
- name: deploy
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
32 changes: 32 additions & 0 deletions scripts/all_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import argparse
import json
import sys
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path


def read_json(path):
with open(path) as f:
data = json.load(f)
return path.stem, data["feedstocks"]


def main(sources_dir, output_json):
jsons = Path(sources_dir).glob("**/*.json")

with ThreadPoolExecutor(4) as executor:
all_packages = {pkg: repos for (pkg, repos) in executor.map(read_json, jsons)}
print(f"Processed {len(all_packages)} packages.")
output_json = Path(output_json)
output_json.parent.mkdir(exist_ok=True, parents=True)
with open(output_json, "w") as f:
json.dump(all_packages, f, separators=(",", ":"), sort_keys=True)


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("sources_dir")
parser.add_argument("output_json")
args = parser.parse_args()

sys.exit(main(args.sources_dir, args.output_json))