-
Notifications
You must be signed in to change notification settings - Fork 7.3k
[Download] Resolve the revision once at the beginning of from_pretrained #14340
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,12 +119,10 @@ def test_cached_files_are_used_when_no_internet(self): | |
|
|
||
| def test_local_files_only_with_sharded_checkpoint(self): | ||
| repo_id = "hf-internal-testing/tiny-flux-sharded" | ||
| error_response = mock.Mock( | ||
| status_code=500, | ||
| headers={}, | ||
| raise_for_status=mock.Mock(side_effect=HfHubHTTPError("Server down", response=mock.Mock())), | ||
| json=mock.Mock(return_value={}), | ||
| ) | ||
| error_response = mock.Mock(status_code=500, headers={}, json=mock.Mock(return_value={})) | ||
| # `resolve_revision` inspects `error.response.status_code` to tell a Hub outage from a definitive answer, | ||
| # so the raised error has to carry the response itself. | ||
| error_response.raise_for_status = mock.Mock(side_effect=HfHubHTTPError("Server down", response=error_response)) | ||
|
Comment on lines
-122
to
+125
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the advantage of doing
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because before we were doing error_response = mock.Mock(
status_code=500,
headers={},
raise_for_status=mock.Mock(side_effect=HfHubHTTPError("Server down", response=mock.Mock(status_code=500))),
json=mock.Mock(return_value={}),
)but that created 2 mocks for the same logical thing (the "response mock") Still fine for me to revert, would you prefer that? |
||
| client_mock = mock.Mock() | ||
| client_mock.get.return_value = error_response | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,9 +112,10 @@ def test_kwargs_local_files_only(self): | |
| tmpdirname = DiffusionPipeline.download(repo) | ||
| tmpdirname = Path(tmpdirname) | ||
|
|
||
| # edit commit_id to so that it's not the latest commit | ||
| # edit commit_id to so that it's not the latest commit. It has to stay a syntactically valid commit hash: | ||
| # `refs/main` is read back by `resolve_revision` and passed around as a commit hash. | ||
| commit_id = tmpdirname.name | ||
| new_commit_id = commit_id + "hug" | ||
| new_commit_id = "0" * len(commit_id) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool! |
||
|
|
||
| ref_dir = tmpdirname.parent.parent / "refs/main" | ||
| with open(ref_dir, "w") as f: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could I get an explanation on why this is needed (to pass the revision here)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not mandatory but doing so the
model._diffusers_load_idis strictly the same as before