-
Notifications
You must be signed in to change notification settings - Fork 32k
Remove redundant error logging in from_pretrained() method #15631
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1366,23 +1366,20 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P | |
| user_agent=user_agent, | ||
| ) | ||
|
|
||
| except RepositoryNotFoundError as err: | ||
| logger.error(err) | ||
| except RepositoryNotFoundError: | ||
| raise EnvironmentError( | ||
| f"{pretrained_model_name_or_path} is not a local folder and is not a valid model identifier " | ||
| "listed on 'https://huggingface.co/models'\nIf this is a private repository, make sure to pass a " | ||
| "token having permission to this repo with `use_auth_token` or log in with `huggingface-cli " | ||
| "login` and pass `use_auth_token=True`." | ||
| ) | ||
| except RevisionNotFoundError as err: | ||
| logger.error(err) | ||
| except RevisionNotFoundError: | ||
| raise EnvironmentError( | ||
| f"{revision} is not a valid git identifier (branch name, tag name or commit id) that exists for " | ||
| "this model name. Check the model page at " | ||
| f"'https://huggingface.co/{pretrained_model_name_or_path}' for available revisions." | ||
| ) | ||
| except EntryNotFoundError as err: | ||
|
Member
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. This is the specific error that's raised when one tries to load a pure TF model in an env with both frameworks installed. I removed the other logs for consistency, but we could just remove this one if desired |
||
| logger.error(err) | ||
| except EntryNotFoundError: | ||
| if filename == WEIGHTS_NAME: | ||
| has_file_kwargs = { | ||
| "revision": revision, | ||
|
|
@@ -1403,7 +1400,6 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P | |
| "weights." | ||
| ) | ||
| else: | ||
| logger.error(err) | ||
| raise EnvironmentError( | ||
| f"{pretrained_model_name_or_path} does not appear to have a file named {WEIGHTS_NAME}, " | ||
| f"{TF2_WEIGHTS_NAME}, {TF_WEIGHTS_NAME} or {FLAX_WEIGHTS_NAME}." | ||
|
|
@@ -1412,17 +1408,15 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P | |
| raise EnvironmentError( | ||
| f"{pretrained_model_name_or_path} does not appear to have a file named {filename}." | ||
| ) | ||
| except HTTPError as err: | ||
| logger.error(err) | ||
| except HTTPError: | ||
| raise EnvironmentError( | ||
| "We couldn't connect to 'https://huggingface.co/' to load this model and it looks like " | ||
| f"{pretrained_model_name_or_path} is not the path to a directory conaining a a file named " | ||
| f"{WEIGHTS_NAME}, {TF2_WEIGHTS_NAME}, {TF_WEIGHTS_NAME} or {FLAX_WEIGHTS_NAME}.\n" | ||
| "Checkout your internet connection or see how to run the library in offline mode at " | ||
| "'https://huggingface.co/docs/transformers/installation#offline-mode'." | ||
| ) | ||
| except EnvironmentError as err: | ||
| logger.error(err) | ||
| except EnvironmentError: | ||
| raise EnvironmentError( | ||
| f"Can't load the model for '{pretrained_model_name_or_path}'. If you were trying to load it from " | ||
| "'https://huggingface.co/models', make sure you don't have a local directory with the same name. " | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Technically, this instance of
logging.error(err)has nothing to do withfrom_pretrained()but I decided to remove it for consistency.