Skip to content

Harden TechJournalist media bootstrap per PR #537 review feedback#540

Merged
leestott merged 2 commits into
mainfrom
copilot/fix-code-for-review-comments
May 13, 2026
Merged

Harden TechJournalist media bootstrap per PR #537 review feedback#540
leestott merged 2 commits into
mainfrom
copilot/fix-code-for-review-comments

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

Bug Fix

What was the bug?

This PR addresses all actionable comments in the linked PR #537 review thread for the Phi-4 TechJournalist notebook. The notebook’s media bootstrap path lacked bounded download/error handling, and image loading could retain an open file handle.

How did you fix it?

  • Media download reliability

    • Added Path("media") bootstrap and standardized image_path / audio_path.
    • Replaced unbounded retrieval with a timeout-bound download path.
    • Wrapped download failures with a clear, actionable RuntimeError instructing manual placement under media/.
  • Resource handling for image input

    • Updated image loading to use a context manager and copy the image into memory to avoid lingering file handles.
  • Notebook wiring updates

    • Added urllib.request and Path imports required by the new bootstrap logic.
    • Switched audio/image reads from hardcoded local files to the new media paths.
for path, url in sample_media.items():
    if not path.exists():
        try:
            with urllib.request.urlopen(url, timeout=30) as response, open(path, "wb") as out_file:
                out_file.write(response.read())
        except Exception as exc:
            raise RuntimeError(
                f"Failed to download {path.name} from {url}. Download it manually and place it under {media_dir}/"
            ) from exc

with Image.open(image_path) as img:
    image = img.copy()

Testing

Scope is limited to the requested review-thread fixes in the notebook.

Copilot AI changed the title [WIP] Fix code based on review comments Harden TechJournalist media bootstrap per PR #537 review feedback May 13, 2026
Copilot AI requested a review from leestott May 13, 2026 09:53
@leestott leestott marked this pull request as ready for review May 13, 2026 09:55
@leestott leestott merged commit 3624464 into main May 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants