From cedffa52879ebc5e4df43f0bcf8660ee7229f0dc Mon Sep 17 00:00:00 2001 From: Sylvain Lesage Date: Thu, 22 Aug 2024 16:33:52 +0200 Subject: [PATCH] don't mention the script if trust_remote_code=False (#7120) --- src/datasets/load.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/datasets/load.py b/src/datasets/load.py index e88358cdcd2..c5f0007d83c 100644 --- a/src/datasets/load.py +++ b/src/datasets/load.py @@ -1658,15 +1658,23 @@ def dataset_module_factory( if isinstance(e1, (DataFilesNotFoundError, DatasetNotFoundError, EmptyDatasetError)): raise e1 from None if isinstance(e1, FileNotFoundError): - raise FileNotFoundError( - f"Couldn't find a dataset script at {relative_to_absolute_path(combined_path)} or any data file in the same directory. " - f"Couldn't find '{path}' on the Hugging Face Hub either: {type(e1).__name__}: {e1}" - ) from None + if trust_remote_code: + raise FileNotFoundError( + f"Couldn't find a dataset script at {relative_to_absolute_path(combined_path)} or any data file in the same directory. " + f"Couldn't find '{path}' on the Hugging Face Hub either: {type(e1).__name__}: {e1}" + ) from None + else: + raise FileNotFoundError( + f"Couldn't find any data file at {relative_to_absolute_path(path)}. " + f"Couldn't find '{path}' on the Hugging Face Hub either: {type(e1).__name__}: {e1}" + ) from None raise e1 from None - else: + elif trust_remote_code: raise FileNotFoundError( f"Couldn't find a dataset script at {relative_to_absolute_path(combined_path)} or any data file in the same directory." ) + else: + raise FileNotFoundError(f"Couldn't find any data file at {relative_to_absolute_path(path)}.") def load_dataset_builder(