[ 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:
@@ -43,6 +43,7 @@ from huggingface_hub.file_download import REGEX_COMMIT_HASH, http_get
|
|||||||
from huggingface_hub.utils import (
|
from huggingface_hub.utils import (
|
||||||
EntryNotFoundError,
|
EntryNotFoundError,
|
||||||
GatedRepoError,
|
GatedRepoError,
|
||||||
|
HFValidationError,
|
||||||
LocalEntryNotFoundError,
|
LocalEntryNotFoundError,
|
||||||
RepositoryNotFoundError,
|
RepositoryNotFoundError,
|
||||||
RevisionNotFoundError,
|
RevisionNotFoundError,
|
||||||
@@ -491,7 +492,10 @@ def cached_file(
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
raise EnvironmentError(f"There was a specific connection error when trying to load {path_or_repo_id}:\n{err}")
|
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
|
return resolved_file
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ class ConfigTester(object):
|
|||||||
|
|
||||||
self.parent.assertEqual(config_second.to_dict(), config_first.to_dict())
|
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):
|
def create_and_test_config_from_and_save_pretrained_subfolder(self):
|
||||||
config_first = self.config_class(**self.inputs_dict)
|
config_first = self.config_class(**self.inputs_dict)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user