mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 10:12:23 +06:00
[ PretrainedConfig
] Improve messaging (#27438)
* import hf error * nits * fixup * catch the error at the correct place * style * improve message a tiny bit * Update src/transformers/utils/hub.py Co-authored-by: Lucain <lucainp@gmail.com> * add a test --------- Co-authored-by: Lucain <lucainp@gmail.com>
This commit is contained in:
parent
453079c7f8
commit
48ba1e074f
@ -43,6 +43,7 @@ from huggingface_hub.file_download import REGEX_COMMIT_HASH, http_get
|
||||
from huggingface_hub.utils import (
|
||||
EntryNotFoundError,
|
||||
GatedRepoError,
|
||||
HFValidationError,
|
||||
LocalEntryNotFoundError,
|
||||
RepositoryNotFoundError,
|
||||
RevisionNotFoundError,
|
||||
@ -491,7 +492,10 @@ def cached_file(
|
||||
return None
|
||||
|
||||
raise EnvironmentError(f"There was a specific connection error when trying to load {path_or_repo_id}:\n{err}")
|
||||
|
||||
except HFValidationError as e:
|
||||
raise EnvironmentError(
|
||||
f"Incorrect path_or_model_id: '{path_or_repo_id}'. Please provide either the path to a local folder or the repo_id of a model on the Hub."
|
||||
) from e
|
||||
return resolved_file
|
||||
|
||||
|
||||
|
@ -96,6 +96,9 @@ class ConfigTester(object):
|
||||
|
||||
self.parent.assertEqual(config_second.to_dict(), config_first.to_dict())
|
||||
|
||||
with self.parent.assertRaises(OSError):
|
||||
self.config_class.from_pretrained(f".{tmpdirname}")
|
||||
|
||||
def create_and_test_config_from_and_save_pretrained_subfolder(self):
|
||||
config_first = self.config_class(**self.inputs_dict)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user