Skip to content

Commit ff737f2

Browse files
committed
feat: enhance error handling and logging for GitHub token permissions in download process
1 parent 201bb5d commit ff737f2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scripts/download_auto_examples.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ def download_and_extract_examples(download_url: str, target_dir: Path) -> bool:
386386
try:
387387
error_data = e.response.json()
388388
if "actions scope" in error_data.get("message", "").lower():
389+
log_message(error_data.get("message", ""))
389390
log_message("Error: GitHub token lacks 'actions:read' scope required for artifact download")
390391
log_message("Please ensure GITHUB_TOKEN has the necessary permissions")
391392
else:
@@ -636,6 +637,10 @@ def main() -> None:
636637

637638
if is_rtd:
638639
log_message("Running on ReadTheDocs environment")
640+
# For ReadTheDocs, enable placeholders by default to ensure builds don't fail
641+
config["create_placeholders"] = True
642+
config["use_local_examples"] = True
643+
log_message("RTD: Enabled fallback strategies (placeholders + local examples)")
639644
elif is_ci:
640645
log_message("Running in CI environment")
641646

@@ -823,7 +828,12 @@ def main() -> None:
823828
2. Alternative: Use GitHub releases instead of artifacts (no token needed)
824829
3. Ensure workflow artifacts exist and haven't expired (30-day retention)"""
825830
log_message(error_msg)
826-
exit(1)
831+
# For ReadTheDocs, don't exit with error - let it fall back gracefully
832+
if is_rtd:
833+
log_message("RTD: Continuing with build despite download failures - will use local examples or placeholders")
834+
log_message("This is expected if no GITHUB_TOKEN is configured in RTD project settings")
835+
else:
836+
exit(1)
827837
else:
828838
log_message(error_msg)
829839
log_message("Sphinx-gallery will generate examples during build if local examples exist")

0 commit comments

Comments
 (0)