Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect offline mode when loading pipeline #6456

Merged
merged 2 commits into from
Jan 4, 2024
Merged

Conversation

Wauplin
Copy link
Collaborator

@Wauplin Wauplin commented Jan 4, 2024

Should close #6168.

This PR adds two behaviors:

  • if offline mode is activated (i.e. HF_HUB_OFFLINE=1), we catch the error raised by huggingface_hub and default back to using the local files.
  • if a ConnectionError happens while fetching model info, we catch the error and also default back to local files

In both cases, if local files don't exist an error will be raised later in the code (as we can't load the pipeline).

This PR should definitely settle the problems for users with slow/low connections. cc @sayakpaul with whom we discussed it at some point.

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

🫶

@HuggingFaceDocBuilderDev

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.

@Wauplin
Copy link
Collaborator Author

Wauplin commented Jan 4, 2024

Thanks for the review :)

@Wauplin Wauplin merged commit 691d8d3 into main Jan 4, 2024
16 checks passed
@voytez
Copy link

voytez commented Jan 4, 2024

Broke my build with error:

cannot import name 'OfflineModeIsEnabled' from 'huggingface_hub.utils' (/opt/conda/lib/python3.8/site-packages/huggingface_hub/utils/init.py)

Was working fine before the commit

@voytez
Copy link

voytez commented Jan 4, 2024

perhaps because im running huggingface_hub-0.19.4 instead of 0.20.1?

@Wauplin Wauplin mentioned this pull request Jan 5, 2024
@Wauplin
Copy link
Collaborator Author

Wauplin commented Jan 5, 2024

Thanks for reporting @voytez! I overlooked this part but indeed, we need to update the huggingface_hub dependency to benefit from the offline mode here. I opened a PR to fix this: #6467.

@Wauplin Wauplin mentioned this pull request Jan 17, 2024
@sayakpaul sayakpaul deleted the respect-offline-mode branch January 17, 2024 14:36
patrickvonplaten pushed a commit that referenced this pull request Jan 17, 2024
* Respect offline mode when loading model

* default to local entry if connectionerror
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* Respect offline mode when loading model

* default to local entry if connectionerror
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.

Working offline automatically after model has downloaded
4 participants