Skip to content
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
26 changes: 13 additions & 13 deletions docs/vitepress/external_repos.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
https://github.com/kmarchais/mmgpy:
topics: [trame, trame-app, vtk]
image: "https://github.com/kmarchais/mmgpy/raw/main/assets/mechanical_piece_remeshing.png"
remoteImage: "https://github.com/kmarchais/mmgpy/raw/main/assets/mechanical_piece_remeshing.png"

https://github.com/dhruvhaldar/FOAMFlask:
image: "https://github.com/dhruvhaldar/FOAMFlask/raw/dev_pyvista_ts_lkgc/Screenshots/geometry.png"
remoteImage: "https://github.com/dhruvhaldar/FOAMFlask/raw/dev_pyvista_ts_lkgc/Screenshots/geometry.png"

https://github.com/MBradley1985/ViSAGE:
topics: [trame, trame-app]
image: "https://raw.githubusercontent.com/MBradley1985/ViSAGE/main/docs/images/hero.png"
remoteImage: "https://raw.githubusercontent.com/MBradley1985/ViSAGE/main/docs/images/hero.png"

https://github.com/jwindgassen/jupyter-trame-proxy:
topics: [trame, trame-app, paraview]

https://github.com/utkarshayachit/simplified-batch:
topics: [trame, trame-app, paraview]
image: https://raw.githubusercontent.com/utkarshayachit/simplified-batch/refs/heads/main/images/trame.gif
remoteImage: https://raw.githubusercontent.com/utkarshayachit/simplified-batch/refs/heads/main/images/trame.gif

https://github.com/vicentebolea/virtual-thermostat:
topics: [trame, trame-app]

https://github.com/linson7017/pymipf:
topics: [trame, trame-app, vtk]
image: "https://github.com/linson7017/pymipf/raw/master/imgs/multi_view.png"
remoteImage: "https://github.com/linson7017/pymipf/raw/master/imgs/multi_view.png"

https://github.com/ndminhvn/interactive-population-visualization:
topics: [trame, trame-app, vtk]

https://github.com/Chahat08/BioSET_Visualizer:
topics: [trame, trame-app, vtk]
image: https://raw.githubusercontent.com/Chahat08/BioSET_Visualizer/master/src/bioset/ui/assets/icon.jpg
remoteImage: https://raw.githubusercontent.com/Chahat08/BioSET_Visualizer/master/src/bioset/ui/assets/icon.jpg

# https://github.com/jph6366/trame-aoc:
# topics: [trame, trame-app]

https://github.com/brendanjmeade/fennil:
topics: [trame, trame-app, py-deck]
image: "https://raw.githubusercontent.com/brendanjmeade/fennil/main/fennil.jpg"
remoteImage: "https://raw.githubusercontent.com/brendanjmeade/fennil/main/fennil.jpg"
trusted: true

https://github.com/brendanjmeade/parsli:
topics: [trame, trame-app, vtk]
image: "https://raw.githubusercontent.com/brendanjmeade/parsli/refs/heads/main/parsli.png"
remoteImage: "https://raw.githubusercontent.com/brendanjmeade/parsli/refs/heads/main/parsli.png"
trusted: true

https://github.com/XAITK/xaitk-saliency-web-demo:
topics: [trame, trame-app]
image: "https://raw.githubusercontent.com/XAITK/xaitk-saliency-web-demo/refs/heads/master/gallery/xaitk.png"
remoteImage: "https://raw.githubusercontent.com/XAITK/xaitk-saliency-web-demo/refs/heads/master/gallery/xaitk.png"
trusted: true

https://github.com/festim-dev/festim-gui:
Expand All @@ -54,17 +54,17 @@ https://github.com/festim-dev/festim-gui:

https://github.com/cardinalgeo/drilldown:
topics: [trame, trame-app, vtk]
image: "https://github.com/cardinalgeo/drilldown/raw/main/media/poster.jpg"
remoteImage: "https://github.com/cardinalgeo/drilldown/raw/main/media/poster.jpg"

https://github.com/MXJK851/SpinView:
topics: [trame, trame-app]
image: "https://github.com/MXJK851/SpinView/raw/main/docs/assets/readme.png"
remoteImage: "https://github.com/MXJK851/SpinView/raw/main/docs/assets/readme.png"

https://gitlab.kitware.com/keu-public/trame-catalyst-demo:
topics: [trame, trame-app, paraview]
nameWithOwner: "keu-public/trame-catalyst-demo"
name: "trame-catalyst-demo"
image: "https://gitlab.kitware.com/keu-public/trame-catalyst-demo/-/raw/main/screenshot.png"
remoteImage: "https://gitlab.kitware.com/keu-public/trame-catalyst-demo/-/raw/main/screenshot.png"
commitCount: 10
createdAt: "2026-05-07T00:00:00Z"
description: "A trame application for Catalyst live visualization."
Expand All @@ -75,5 +75,5 @@ https://gitlab.kitware.com/keu-public/trame-catalyst-demo:

https://github.com/epicsuite/episcope:
topics: [trame, trame-app, paraview]
image: https://raw.githubusercontent.com/epicsuite/episcope/refs/heads/main/doc/img/selection.gif
remoteImage: https://raw.githubusercontent.com/epicsuite/episcope/refs/heads/main/doc/img/selection.gif
trusted: true
62 changes: 59 additions & 3 deletions docs/vitepress/fetch_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,33 @@
import json
import re
from datetime import datetime, timedelta, timezone
import requests
import warnings
import time
import yaml
from pathlib import Path

EXTERNAL_REPOS_FILE = "external_repos.yml"
OUTPUT_FILE = "repos.json"
IMAGES_DOWNLOAD_DIR = Path("public/repos_images")
IMAGES_SERVE_SUFFIX = "/trame/repos_images"


class ImageCacheMaker:
"""Downloads remote images to make the page serve them itself"""

_img_id = 0

def __init__(self, download_dir: Path, serve_url_suffix_base: str):
"""download_dir must be served at serve_url_suffix_base"""
self._download_dir = download_dir
self._serve_url_suffix_base = serve_url_suffix_base

def download(self, url: str):
download_remote_image(url, self._download_dir / f"{self._img_id}.png")
serve_url_suffix = f"{self._serve_url_suffix_base}/{self._img_id}.png"
self._img_id += 1
return serve_url_suffix


def minify_graphql(query):
Expand All @@ -56,7 +78,7 @@ def make_gh_request(request: list[str]):
result = subprocess.run(request, capture_output=True, text=True, env=os.environ)
if result.returncode != 0:
raise Exception(
f"Error executing command {' '.join(request)}:\n{result.stderr}"
f"Error executing command {' '.join(request)[:100]}:\n{result.stderr}\n{result.stdout}"
)
return result.stdout

Expand Down Expand Up @@ -85,6 +107,35 @@ def retrieve_gh_repos_from_topic(topic: str, owners: list = []):
return repos


def download_remote_image(remote_url: str, local_path: str, max_retries: int = 5):
for attempt in range(max_retries):
response = requests.get(remote_url)

if response.status_code == 200:
with open(local_path, "wb") as file:
file.write(response.content)
print(f" Saved {local_path}")
return

if response.status_code == 429: # Too many requests
retry_after = response.headers.get("Retry-After")
wait = float(retry_after) if retry_after else (2**attempt)
print(
f" Rate limited fetching {remote_url}, retrying in {wait:.1f}s "
f"(attempt {attempt + 1}/{max_retries})..."
)
time.sleep(wait)
continue

raise Exception(
f"Failed to download {remote_url}, status code: {response.status_code}"
)

raise Exception(
f"Failed to download {remote_url} after {max_retries} retries (still rate limited)."
)


def retrieve_repos_from_file(filename: str) -> list[str]:
with open(filename, "r") as f:
repos = yaml.safe_load(f)
Expand Down Expand Up @@ -169,7 +220,7 @@ def repos_data_to_json(repos_data):
fetched_repos[url] = {
"name": repo_data["name"],
"description": repo_data["description"] or "",
"image": repo_data["openGraphImageUrl"],
"remoteImage": repo_data["openGraphImageUrl"],
"topics": topics,
"createdAt": repo_data["createdAt"],
"lastCommitDate": last_commit_date,
Expand Down Expand Up @@ -197,6 +248,7 @@ def fetch_gh_info(gh_repos):


def add_info(repos):
image_cache_maker = ImageCacheMaker(IMAGES_DOWNLOAD_DIR, IMAGES_SERVE_SUFFIX)
one_year_ago = datetime.now(timezone.utc) - timedelta(days=365)
for url, repo_info in repos.items():
if not repo_info["trusted"]:
Expand All @@ -207,6 +259,8 @@ def add_info(repos):
)
repo_info["createdWithinLastYear"] = created_at >= one_year_ago

repo_info["image"] = image_cache_maker.download(repo_info["remoteImage"])


if __name__ == "__main__":
print("- Discovering trusted repositories from GitHub...")
Expand All @@ -230,7 +284,9 @@ def add_info(repos):
print(f"- Fetching GraphQL metadata for {len(gh_repos)} GitHub repositories...")
fetched_gh_repos = fetch_gh_info(gh_repos)

print("- Enriching repository information and calculating age...")
print(
"- Enriching repository information, downloading images and calculating age..."
)
repos_w_info = non_gh_repos | fetched_gh_repos
add_info(repos_w_info)

Expand Down
1 change: 1 addition & 0 deletions docs/vitepress/public/repos_images/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.png
2 changes: 1 addition & 1 deletion docs/vitepress/repos.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/vitepress/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pyyaml
pyyaml
requests
Loading