Unverified Commit 000e52ae authored by Matt's avatar Matt Committed by GitHub
Browse files

More error message fixup, plus some linebreaks! (#26296)



* More error message fixup, plus some linebreaks!

* Update src/transformers/dynamic_module_utils.py
Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>

* Update src/transformers/dynamic_module_utils.py
Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>

* Update src/transformers/dynamic_module_utils.py
Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>

---------
Co-authored-by: default avatarArthur <48595927+ArthurZucker@users.noreply.github.com>
parent 9a307534
...@@ -575,9 +575,8 @@ def custom_object_save(obj: Any, folder: Union[str, os.PathLike], config: Option ...@@ -575,9 +575,8 @@ def custom_object_save(obj: Any, folder: Union[str, os.PathLike], config: Option
def _raise_timeout_error(signum, frame): def _raise_timeout_error(signum, frame):
raise ValueError( raise ValueError(
"Loading this model requires you to execute the configuration file in that repo on your local machine. We " "Loading this model requires you to execute custom code contained in the model repository on your local"
"asked if it was okay but did not get an answer. Make sure you have read the code there to avoid malicious " "machine. Please set the option `trust_remote_code=True` to permit loading of this model."
"use, then set the option `trust_remote_code=True` to remove this error."
) )
...@@ -594,9 +593,9 @@ def resolve_trust_remote_code(trust_remote_code, model_name, has_local_code, has ...@@ -594,9 +593,9 @@ def resolve_trust_remote_code(trust_remote_code, model_name, has_local_code, has
signal.alarm(TIME_OUT_REMOTE_CODE) signal.alarm(TIME_OUT_REMOTE_CODE)
while trust_remote_code is None: while trust_remote_code is None:
answer = input( answer = input(
f"The repository for {model_name} contains custom code which must be executed to correctly " f"The repository for {model_name} contains custom code which must be executed to correctly"
f"load the model. You can inspect the repository content at https://hf.co/{model_name}. " f"load the model. You can inspect the repository content at https://hf.co/{model_name}.\n"
f"You can avoid this prompt in future by passing the argument `trust_remote_code=True`.\n" f"You can avoid this prompt in future by passing the argument `trust_remote_code=True`.\n\n"
f"Do you wish to run the custom code? [y/N] " f"Do you wish to run the custom code? [y/N] "
) )
if answer.lower() in ["yes", "y", "1"]: if answer.lower() in ["yes", "y", "1"]:
...@@ -607,8 +606,8 @@ def resolve_trust_remote_code(trust_remote_code, model_name, has_local_code, has ...@@ -607,8 +606,8 @@ def resolve_trust_remote_code(trust_remote_code, model_name, has_local_code, has
except Exception: except Exception:
# OS which does not support signal.SIGALRM # OS which does not support signal.SIGALRM
raise ValueError( raise ValueError(
f"The repository for {model_name} contains custom code which must be executed to correctly " f"The repository for {model_name} contains custom code which must be executed to correctly"
f"load the model. You can inspect the repository content at https://hf.co/{model_name}. " f"load the model. You can inspect the repository content at https://hf.co/{model_name}.\n"
f"Please pass the argument `trust_remote_code=True` to allow custom code to be run." f"Please pass the argument `trust_remote_code=True` to allow custom code to be run."
) )
elif has_remote_code: elif has_remote_code:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment