Skip to content

[Docs] Fix from_pretrained integration example - #5105

Merged
hanouticelina merged 1 commit into
huggingface:mainfrom
Ayushdevo:docs/fix-from-pretrained-example
Oct 7, 2026
Merged

hanouticelina merged 1 commit into
huggingface:mainfrom
Ayushdevo:docs/fix-from-pretrained-example

Conversation

@Ayushdevo

@Ayushdevo Ayushdevo commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Use consistent indentation so the integration guide's from_pretrained example can be parsed as Python.
  • Pass the function's model_id argument to hf_hub_download, instead of the undefined repo_id. For example, from_pretrained("test/model") now forwards repo_id="test/model".

Validation

  • Confirmed the original snippet raises IndentationError; the corrected snippet parses successfully.
  • Executed the corrected function with mocked download/load helpers and verified the requested model ID and loaded result.
  • make style passed. Ruff lint/format and repository consistency checks passed; ty check src passed.
  • make quality remains blocked by an existing generated CLI reference mismatch in docs/source/en/package_reference/cli.md. That unrelated file is unchanged in this PR.
  • Documentation build and full test suite were not run.

AI assistance was used to identify, verify, and prepare this documentation fix.


Note

Low Risk
Documentation-only change to a code snippet; no runtime or API behavior is affected.

Overview
Corrects the integrations guide’s sample from_pretrained implementation so it is valid, copy-pasteable Python.

The example body is indented consistently inside the function, and hf_hub_download now uses repo_id=model_id instead of an undefined repo_id, matching the model_id parameter shown in the signature.

Reviewed by Cursor Bugbot for commit d9396ae. Bugbot is set up for automated code reviews on this repo. Configure here.

@hanouticelina hanouticelina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@bot-ci-comment

bot-ci-comment Bot commented Oct 7, 2026

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@hanouticelina
hanouticelina merged commit bb3a875 into huggingface:main Oct 7, 2026
6 of 7 checks passed
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v2.2.0 release.

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