Skip to content

Use requests instead of urllib in convert_consistency_decoder _download#13985

Open
islem-esi wants to merge 1 commit into
huggingface:mainfrom
islem-esi:use-requests-in-consistency-decoder-download
Open

Use requests instead of urllib in convert_consistency_decoder _download#13985
islem-esi wants to merge 1 commit into
huggingface:mainfrom
islem-esi:use-requests-in-consistency-decoder-download

Conversation

@islem-esi

Copy link
Copy Markdown

What does this PR do?

Refactors the _download helper in scripts/convert_consistency_decoder.py to use requests
(already a diffusers dependency) instead of urllib.request. The streaming download, SHA-256
verification, and tqdm progress bar are preserved. It is also slightly more robust: the original
did int(source.info().get("Content-Length")), which raises if the header is absent; this version
tolerates a missing Content-Length (passes total=None to tqdm).

with requests.get(url, stream=True) as response:
    response.raise_for_status()
    total = response.headers.get("Content-Length")
    total = int(total) if total is not None else None
    ... iter_content(8192) ...

No new dependency. ruff check and ruff format --check pass.

Before submitting

  • Did you use an AI agent (Claude Code, Codex, Cursor, etc.) to help with this PR? If so:
  • Did you read the contributor guideline?
  • Was this discussed/approved via a GitHub issue? (No, small, self-contained script refactor)
  • Documentation update (None)
  • Did you write any new necessary tests? (one-off conversion script; behavior preserved)

@github-actions github-actions Bot added the size/S PR with diff < 50 LOC label Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi @islem-esi, thanks for the PR! It does not appear to link an issue it fixes. If this PR addresses an existing issue, please add a closing keyword (e.g. Fixes #1234) to the PR description so the issue is linked. See the contribution guide for more details. If this PR intentionally does not fix a tracked issue, a maintainer can add the no-issue-needed label to silence this reminder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant